How to create (function executeRule(current, previous /*null when async*/) using String operations programmatically to do a successful POST to BusinessRule?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2020 10:00 AM
I have been able to create Business Rule programmatically but need some help there: This is the script i want to create in Advanced tab:
(function executeRule(current, previous /*null when async*/) {
var strBody = "{";
strBody += "'Id': '" + current.number.toString() + "', ";
strBody += "'Title': '" + current.short_description.toString() + "', ";
strBody += "'Description': '" + current.description.toString() + "', ";
strBody += "'Category': '" + current.category.toString() + "', ";
strBody += "'Impact': '" + current.impact.toString() + "',";
strBody += "'Urgency': '" + current.urgency.toString() + "'";
strBody += "}";
var request = new sn_ws.RESTMessageV2('YourNameSpace', 'APIName');
request.setRequestBody(JSON.stringify(strBody));
var response = request.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
})(current, previous);
The example was given to me above has a simple script but will appreciate if you guys can help me how to add it to below postData that i m using to create my business rule:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2020 10:09 PM
Hi Siddharth,
can you explain what you are trying to achieve?
are you saying you want to set the request body?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2020 10:11 PM
You mean to INSERT a business rule record using POST operation?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2020 10:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2020 08:51 PM
Hi Siddharth,
Any update on this?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader