Cloud Pak for Business Automation

Cloud Pak for Business Automation

Come for answers. Stay for best practices. All we’re missing is you.

 View Only
  • 1.  Call an ADS decision through a Script in BAW.

    Posted Fri November 08, 2024 03:18 PM

    Hello everyone, could you help me with the information on how I could call an ADS decision through a Script in BAW.

    Thanks a lot.



    ------------------------------
    David Salgado
    ------------------------------


  • 2.  RE: Call an ADS decision through a Script in BAW.

    Posted Mon November 11, 2024 11:33 AM

    Hi David , 

    please use this script below 

    var url = "http://<ODM_SERVER>/decisionservice/rest/decision/{decision-service-name}"; var requestBody = { // Your input parameters for the decision service "inputParameter1": "value1", "inputParameter2": "value2" }; var headers = { "Content-Type": "application/json", "Authorization": "Basic <base64-encoded-credentials>" // Optional, if authentication is required }; // Function to make the REST call function callDecisionService() { var http = new XMLHttpRequest(); http.open("POST", url, true); // Set request headers for (var key in headers) { if (headers.hasOwnProperty(key)) { http.setRequestHeader(key, headers[key]); } } // Define what happens when the request completes http.onreadystatechange = function() { if (http.readyState == 4 && http.status == 200) { // Handle success response (decision output) var response = JSON.parse(http.responseText); console.log("Decision response: ", response); // You can process the response further or pass it into the workflow // e.g., set a process variable with the result task.setVariable("decisionResult", response); } else if (http.readyState == 4) { // Handle error console.log("Error calling decision service: ", http.status, http.statusText); } }; // Send the request http.send(JSON.stringify(requestBody)); } // Call the decision service callDecisionService();



    ------------------------------
    Mohammed Ghazali
    ------------------------------