Triggering a Power Automate using a Business Rule

Abu5
Tera Contributor

Hi, please can someone help. I am trying to trigger a power automate using a business rule when a catalog item is submitted but I can't pass through the catalog variable from the form as part of the REST body. The body is blank as per the screenshot. The table the business rule is on is the requested table. I am currently on the Vancouver release

 

(function executeRule(current, previous /*null when async*/) {

 

// Define the Power Automate endpoint URL

var powerAutomateEndpoint = 'END POINT GOES HERE'; // Replace with your actual Power Automate endpoint

 

// Define the data to be sent in the request
var requestData = {
"shortDesc": current.short_description
//"field2": current.field2
// Add more fields as needed
};

 

// Set up HTTP Request
var request = new sn_ws.RESTMessageV2();
request.setEndpoint(powerAutomateEndpoint);
request.setHttpMethod('POST');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestBody(JSON.stringify(requestData));

 

// Execute the HTTP Request
var response = request.execute();
var responseBody = response.getBody();

 

// Log the response from Power Automate
gs.info('Power Automate Response: ' + responseBody);

 

// Handle the response as needed, you can parse and process it based on your requirements

})(current, previous);

 

Abu5_0-1702546406540.png

 

2 REPLIES 2

jonsan09
Giga Sage
Giga Sage

You can try using

current.variables.VARIABLE_NAME.getDisplayValue();

ersureshbe
Giga Sage
Giga Sage

Hi, Im not sure what table you  are writing to Business Rule.

If you are writing the business rule on sc_request table then you should write current.variables.variable_name.getDisplayValue() else write the code with below tables.

sc_item_option
sc_item_option_mtom
sc_multi_row_question_answe

Regards,
Suresh.