- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 12:20 AM
I have to build a JSON object in this script and send in rest message:
with this data:
how can i do?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 02:53 AM
Hello
It will be like -
{
"first_name":"${first_name}",
"last_name":"${last_name}",
"active":"${active}"
}
Where $ variable name is the field name we have set in business rule.
Also please check below video. It will clear you all queries.
Kindly let me know if you have any doubts
Thanks
Akshay Kangankar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 12:27 AM
You can create an array
var reqArr = [
{"field": "firstName",
"field_description": "First Name",
"type_format": "STRING",
so on},
{"field": "lastName",
"field_description": "Last Name",
"type_format": "STRING",
so on},
];
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 12:45 AM
Hello,
If you just want to send values from ServiceNow table and If you have created rest message with HTTP header , content-type is "application/json" then you can simply use below code.
In other cases use
(function executeRule(current, previous /*null when async*/) {
try {
var r = new sn_ws.RESTMessageV2('REST Message', 'post');
r.setStringParameterNoEscape(first_name', current.u_name);
r.setStringParameterNoEscape('last_name', current.u_cogname);
r.setStringParameterNoEscape('active', current.active); // so on you can add values and send them
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
}
catch(ex) {
var message = ex.message;
}
})(current, previous);
Reference - Servicenow Integration
Thanks
Akshay Kangankar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 01:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 02:53 AM
Hello
It will be like -
{
"first_name":"${first_name}",
"last_name":"${last_name}",
"active":"${active}"
}
Where $ variable name is the field name we have set in business rule.
Also please check below video. It will clear you all queries.
Kindly let me know if you have any doubts
Thanks
Akshay Kangankar