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

Thanks Chuck, it does the same thing. But good thing that came out of this exercise is that I was able to explore Script Action which I haven't used before. Thank you so much for your help as always. Have a good day!


That's odd. I wonder if the events are being processed in a different order than they are being queued. I would hope it is a FIFO (first in first out), but don't know the event queue management to that detail unfortunately. Sorry that didn't work out. I'll let you know if I come up with any other ideas.


reginabautista
Kilo Sage

Thanks Anurag I've tried this and it worked great.



One thing to note though is that setting workflow to false will disable auditing so I had to set it to true after closing out the status   to add the work notes to the audit log.




var riskRec = new GlideRecord('u_risk');



//proces risk records


  1. riskRec.addEncodedQuery('u_tagLIKE#close^state!=Closed');
  2. riskRec.query();


while(riskRec.next()) {


gs.log('processing sysid-' + riskRec.sys_id);


riskRec.state = 'Closed';


//set workflow to false to disable BR


riskRec.setWorkflow(false);


riskRec.update();



//need to set the workflow to true to add the work notes to the audit log


riskRec.setWorkflow(true);


riskRec.u_work_notes = 'Risk automatically closed according to its heritage risk register state'


riskRec.update();


}


Yes Regina,



This is a pickle we land in a lot of times, if you setWorkflow false then the journal fields don't get updated.


-Anurag