Need to send two rest post messages with one UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 01:23 AM
Hello Team,
Am trying to use two rest messages (post) in one UI action, but only first rest message is getting triggered.
Please help me with any suggestions.
Below is the code.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 01:30 AM - edited 10-16-2023 02:14 AM
(function executeRule(current, previous /*null when async*/ ) {
var sixDigitRandomisedPin = (Math.floor(100000 + Math.random() * 900000)).toString();
sm = new sn_ws.RESTMessageV2('abc, 'xyz');
var requestBody = {
"firstName": current.parent.u_requested_for_tc.first_name.getDisplayValue(),
"middleName": "string",
"lastName": current.parent.u_requested_for_tc.last_name.getDisplayValue(),
"pin": sixDigitRandomisedPin,
};
current.u_pin = sixDigitRandomisedPin;
current.update();
sm.setRequestHeader('Content-Type', 'application/json');
sm.setRequestBody(JSON.stringify(requestBody));
var response = sm.execute();
var httpStatus = response.getStatusCode();
gs.addInfoMessage('Response Status: ' + httpStatus);
gs.addInfoMessage(JSON.stringify(response.getBody()));
gs.addInfoMessage(name);
sm1 = new sn_ws.RESTMessageV2('abc1', 'xyz1');
var requestBody1 = {
"machineAccessNumber": data,
"locationId": current.parent.u_requested_for_tc.location.getDisplayValue(),
"clientTicketNumber": current.number,
};
//current.update();
sm1.setRequestHeader('Content-Type', 'application/json');
sm1.setRequestBody(JSON.stringify(requestBody1));
var responses = sm1.execute();
var httpStatuss = responses.getStatusCode();
gs.addInfoMessage('Response Status: ' + httpStatuss);
gs.addInfoMessage(JSON.stringify(responses.getBody()));
gs.addInfoMessage(name);
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 01:53 AM
Thanks Shruti, let me check your script.
Meanwhile let me know what changes you have done?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 01:54 AM
sm1.setRequestBody(JSON.stringify(requestBody1));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 02:06 AM
Same Shruti, only first rest message was triggered but not second rest message not triggered.