Business rule not trigger

User376867
Tera Contributor
For below Business rule script , BR not triggering the first time ticket assignment

(
function executeRule(current, previous /*null when async*/) {
    var wflw = new Workflow();
var gru = GlideScriptRecordUtil.get(current);
var changedFields = gru.getChangedFields(); //Get changed fields with friendly names
// var changedValues = gru.getChanges(); //Get changed field values
gs.include('j2js');
changedFields = j2js(changedFields);    
function isInArray(value, array) {
  return array.indexOf(value) > -1;
   
}
    if(current.operation() == "update" && current.reassignment_count > 0) {
       
    if(isInArray("Assignment group",changedFields)){
//      gs.addInfoMessage("Update");
        wflw.startFlow(wflw.getWorkflowFromName('Req_Ticket_ Auto_Assignment_CSD'), current, 'update');
    }
    }
    if(current.operation() == "insert"){
//  gs.addInfoMessage("Insert");
    wflw.startFlow(wflw.getWorkflowFromName('Req_Ticket_ Auto_Assignment_CSD'), current, 'update');
    }
})(current, previous);
1 REPLY 1

aizawaken
Tera Guru

hi @User376867 ,

I haven't tried yet but I hope you can refer this page.

I can find using "else if" instead of using "if" clause as below:

 

if(current.operation()=="update") 
{
    // do something
} 
else if(current.operation()=='insert')
{
    // do the other thing
}

 

Or,,, is it caused by wrong setting of "When to run" trigger condition?
 
Thanks!