Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Apply business rule to assign branch manager based on branch field

MitishaV
Tera Contributor
(function executeRule(current, previous /*null when async*/) {

    var branch = current.u_branch;
    var Record = new GlideRecord('u_branch');
   
    Record.addQuery('u_branch',branch);
    Record.query();
   
    if(Record.next())
    {
        var branch_manager = Record.getDisplayBox('u_branch_manager').value;
        current.assigned_to = branch_manager;
    }


})(current, previous);
1 REPLY 1

Shruti
Mega Sage
Mega Sage
  (function executeRule(current, previous /*null when async*/ ) {
      var branch = current.u_branch;
      var rec = new GlideRecord('u_branch');
      rec.addQuery('u_branch', branch);
      rec.query();
      if (rec.next()) {
          current.assigned_to = rec.getValue('u_branch_manager');
      }
  })(current, previous);