Need to send two rest post messages with one UI action
Options
- 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.
(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(requestBody));
var responses = sm1.execute();
var httpStatuss = responses.getStatusCode();
gs.addInfoMessage('Response Status: ' + httpStatuss);
gs.addInfoMessage(JSON.stringify(responses.getBody()));
gs.addInfoMessage(name);
})(current, previous);
Thanks.
10 REPLIES 10
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 02:44 AM
Yes Will the request body and below is the sample request body,
{
"AccessNumber": "string",
"locationId": 0,
"isActive": true,
"clientTicketNumber": "string",
"clientId": 0,
"productId": 0
}