The CreatorCon Call for Content is officially open! Get started here.

Use case for Business Rule

User460980
Kilo Contributor

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);

find_real_file.png

2 REPLIES 2

Anil Lande
Kilo Patron

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

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

can you explain usecase