Paging doesnot work if assignment group populated on new P1, P2 incidents

ShreeyaSatam
Tera Contributor

In ServiceNow Trigger rules fire only if the assigned_to and assignment_group fields are not populated on a record. My requirement is to trigger paging even if incident created with assignment group.

I tried to create BR for this but it doesnot start paging, value for wbc displays null in system logs

BR is on table incident-

condition-

state is new

Priority is one of P1, P2

Assignment group is not empty

 try {
            var vars = {};
            vars.assignment_group = current.assignment_group;
            vars.notified_user_sysid = '';

            var wf = new Workflow();
            var wfc = wf.startFlow("532483e04309b1103424dc5f6ab8f2b7", current, current.operation(), vars);

            gs.info("Workflow started with context: " + wfc);
        } catch (ex) {
            gs.error("Failed to start workflow: " + ex.message);
        }

 

 try {
            var vars = {};
            vars.assignment_group = current.assignment_group;
            vars.notified_user_sysid = '';

            var wf = new Workflow();
            var wfc = wf.startFlow("532483e04309b1103424dc5f6ab8f2b7", current, current.operation(), vars);

            gs.info("Workflow started with context: " + wfc);
        } catch (ex) {
            gs.error("Failed to start workflow: " + ex.message);
        }
 
 
 
3 REPLIES 3

SANDEEP DUTTA
Tera Patron
Tera Patron

Hi @ShreeyaSatam ,

Even i faced this issue !! What i have seen is when an incident is created with a populated assignment_group, the trigger rule does not start the workflow. This is seems to be by design and Trigger rules won't fire if the assignment group or assigned to fields have values at record creation.

What i did was removed the condition on the assignment group in the trigger rule definition so that it fires regardless of assignment group but included other qualifying criteria (like state and priority).

 

Thanks,
Sandeep Dutta

Please mark the answer correct & Helpful, if i could help you.

ShreeyaSatam
Tera Contributor

I am trying to create BR on Incident table which check the trigger rule  condition and if matches it will start the workflow. There are different custom solutions available 

Rafael Batistot
Kilo Patron

Hi @ShreeyaSatam 

 

Here’s a quick summary of how to fix your BR so paging triggers when an Incident is created with an assignment group:

 

  • Run BR after insert (not before).
  • Make sure workflow is active/published.
  • Pass the assignment group as a string:

vars.assignment_group = current.assignment_group.toString();

 

  • Remove the duplicate try/catch block.
  • Use this cleaned script:

 

(function executeRule(current, previous) {
try {
var vars = {};
vars.assignment_group = current.assignment_group.toString();
vars.notified_user_sysid = '';

var wf = new Workflow();
var wfc = wf.startFlow("532483e04309b1103424dc5f6ab8f2b7", current, "insert", vars);

gs.info("Workflow started with context: " + wfc);
} catch (ex) {
gs.error("Failed to start workflow: " + ex.message);
}
})(current, previous);

 

  • Debug with gs.info("AG: " + current.assignment_group); and check wf_context table for workflow runs.