cancel
Showing results for 
Search instead for 
Did you mean: 

script in the layout not showing executeAction function to call OData Service into SAC Layout

08-11-2023 3:23 AM
1163 views 1 comments
0 Likes
SAP Managed Tags
Subscribe

Hi,

I am trying to call a OData service created in BW to run a process chain from SAC, OData service is created and tested in BW successfully, generated the URL.

Now I have included the OData in the SAC layout by selecting the Live Connection.

I am trying to call this in the button, but I am not getting the executeAction() function as suggested in the help documents.

Can you please let me know what is missing.

I was following below blogs:

https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/720744f5ecec4655837bb...

https://blogs.sap.com/2023/04/11/how-to-call-a-bw-abap-backend-from-sac-analytic-application/comment...

Thanks and Regards,

HK

0 Likes

Accepted Solutions (0)

Answers (1)

Answers (1)

vishalakshmi
Contributor
0 Likes

Hello H K,

Go to your SAC story.

Add a Button component to your story canvas.

In the properties of the button, you can set its label and appearance as needed.

Click on the button to select it.

In the Properties pane on the right, scroll down to the "Script" section.

In the script editor, you can write JavaScript code to make a request to your OData service. You can use the fetch API or jQuery.ajax for this purpose

code:

var url = "YOUR_ODATA_SERVICE_URL";

fetch(url, {

method: "GET",

headers: {

"Authorization": "Bearer YOUR_ACCESS_TOKEN", // If authentication is required

"Content-Type": "application/json"

}

})

.then(response => response.json())

.then(data => {

// Handle the OData response data here

console.log(data);

})

.catch(error => {

// Handle any errors here

console.error(error);

});

Replace YOUR_ODATA_SERVICE_URL with the actual URL of your OData service and include any necessary headers or authentication tokens.

Execute the Script on Button Click:

In the script editor, you can use the following code to execute the script when the button is clicked:

this.onClick = function() {

// Place your fetch code or other OData service calling logic here

};

Save your story and then click the button to trigger the OData service call.

Make sure you have proper CORS (Cross-Origin Resource Sharing) and authentication settings configured on your OData service to allow requests from your SAC domain.

Thanks,Lakshmi.