Use case for Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2022 02:15 AM
HI
please explain the BR and conditions with all possible use cases.
(function executeRule(current, previous /*null when async*/ ) {
var OneInstance;
var Instance = gs.getProperty("instance_name");
if (Instance == "dev") {
OneInstance = "dev";
} else if (Instance == "test") {
OneInstance = "uat";
} else if (Instance == "testl") {
OneInstance = "test2";
}
var r = new sn_ws.RESTMessageV2('Incident', 'Stop-Integration');
r.setStringParameterNoEscape('instance', OneInstance);
r.setStringParameterNoEscape('number', current.number);
var comments = current.comments + "-" + current.work_notes;
r.setStringParameterNoEscape('work_notes', comments);
r.setStringParameterNoEscape('u_end_integration', 'true');
if (current.u_field1 == "" && current.assignment_group.source == "company
" && current.assignment_group.changes()) {
r.setStringParameterNoEscape('group', "Infrastructure Networks");
} else if (current.assignment_group.source == "One" && current.assignment_group.changes()) {
var groupName = current.assignment_group.getDisplayValue();
var gn = groupName.split("One");
r.setStringParameterNoEscape('group', gn[1].trim());
}
function jsonEncode(str) {
str = new global.JSON().encode(str);
return str.substring(1, str.length - 1);
}
if (current.comments.changes()) {
//comnts = current.comments.getJournalEntry(1).replace(/(\r\n|\n|\r)/gm, " ");
comnts = current.comments.getJournalEntry(1);
//comnts=jsonEncode(coms + '');
r.setStringParameterNoEscape('comments', jsonEncode(comnts + ''));
}
if (current.work_notes.changes()) {
var worknotes = current.work_notes.getJournalEntry(1);
r.setStringParameterNoEscape('work_notes', jsonEncode(worknotes + ''));
}
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
})(current, previous);
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2022 02:31 AM
Hi,
Looks like this BR is running on incident table.
Based on condition it will execute if any record is inserted or updated and Automation field value changes to (value in BR). This BR will only run for mentioned Domain records when Field1 is not Empty.
In script part it is calling one REST message (you need to check internally what is purpose of this method "Stop-integration").
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2022 02:45 AM
can you explain usecase