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.

Stop triggering email via Fix Script

reginabautista
Kilo Sage

Hi everyone,

I have a requirement where I have run a fix script to set the state of Risk records that has #closed tag. This table has an email notification set up which will be triggered if the record is closed.

As this is an adhoc process, I need to ensure that the notification is not triggered once I run the Fix Script.

Is there a way to accomplish this without de-activating the notification?

Thanks

Regina

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

Hi Regina,



If the emails are triggered via event, from a business rule. then can you use setWorkflow(false) in your fix script which will not let the BRs to run and hence no email.


-Anurag

View solution in original post

13 REPLIES 13

Anurag Tripathi
Mega Patron
Mega Patron

Hi Regina,



If the emails are triggered via event, from a business rule. then can you use setWorkflow(false) in your fix script which will not let the BRs to run and hence no email.


-Anurag

Hi Anurag, Is there any similar way available if my emails are being fired by an event generated from 'create event' workflow activity? Anything without deactivating the workflow would-be helpful.

reginabautista
Kilo Sage

Thanks Anurag for the reply.



I was looking at the Business Rule and it seems that it handles not just the closing of records but other other states also. If I do setWorkflow(false) would this impact other process too?



BR code snippet:


if (current.state.changesTo('Closed')) {


  gs.eventQueue("risk.closed", current, current.state, previous.state);


}



if (current.state.changes() && previous.state == 'Closed' && current.state =='Open') {


  gs.eventQueue("risk.reopened", current, current.state, previous.state);


}



if (current.state.changes() && previous.state != 'Draft' && current.state =='Draft') {


  gs.eventQueue("risk.rollbackToDraft", current, current.state, previous.state);


}


ctomasi any ideas?