setWorkflow and subsequent actions

dmartinc
Tera Expert

Hello all,

I have a question about GlideRecord's .setWorkflow() method.
In its wiki page ( http://wiki.service-now.com/index.php?title=GlideRecord#setWorkflow ) it is written:

[quote]
Enables or disables the running of business rules that might normally be triggered by subsequent actions. (emphasis mine)
[/quote]

In other words, it says that calling .setWorkflow(false) will affect all the following .update() calls.

However in the example script, the .setWorkflow() method is called just before the .update() call, which is inside two while() loops. So it makes it seem like you have to call .setWorkflow(false) before every .update().


Can someone please confirm which one is correct?

My particular context is that I have an "after insert/update" business rule and I am doing a current.update() preceded by a current.setWorkflow(false). However I want to know if I should do a current.setWorflow(true) afterwards so as not to change the behaviour of similar business rules that may be executed afterwards.

6 REPLIES 6

I know this is an old discussion, but I found it helpful in my research for setWorkflow().



oneppo: you ask why you need to have current.update in the script and David gave you a very cogent explanation.   However I have yet another reason.   A scheduled job.     We have a need to populate a field in our change request records prior to making it mandatory.   So in our business rule which runs on demand, we have the update function as well as setWorkflow to avoid any unintended side effects of the update.


After 6+ years, script at http://wiki.service-now.com/index.php?title=GlideRecord#setWorkflow is STILL misleading.


Add, according to "All Active Transactions" if you look at the number of SQL Statements and Business Rules executed, It doesn't work!


If you have used setWorkFlow for performance reasons, I think you all have been fooled.



Furthermore, I see our progress messages in the log that were put there by the business rules that were fired.