What is the use of setWorkflow(false)

ishankaggarwal
Tera Contributor

What is the use of setWorkflow(false)

7 REPLIES 7

Ramesh Lohar
Kilo Guru

The setWorkflow(false) is a method used in ServiceNow scripting. Here's a summary of its use:

- It is used to prevent any business rules from running that are set to run on database changes.
- It is often used when you want to update a record in a script without triggering the business rules or workflows associated with that update.
- It is a method of the GlideRecord class.
- It accepts a boolean value. If set to false, it prevents the running of Business Rules. If set to true, it allows the running of Business Rules.
- It is particularly useful when you want to make changes to a record in a controlled manner, without the potential side effects of other rules or workflows being triggered.
- It should be used with caution, as it can lead to unexpected results if not used correctly. For example, if you have business rules that are critical for data integrity, using setWorkflow(false) could bypass these and lead to data inconsistencies.
- The syntax is as follows: GlideRecord.setWorkflow(false);


nowKB.com

Dr Atul G- LNG
Tera Patron
Tera Patron

According to the documentation Set Work Flow Boolean, setWorkflow(Boolean e) enables or disables the running of business rules that might normally be triggered by subsequent actions. If true (default), it enables business rules. If false, it disables business rules.

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0867584#:~:text=According%20t....

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Kamal Haddou
Tera Contributor

Hello,

 

setWorkflow() is a method of GlideRecord and WorkflowDuration.

 

In GlideRecord it enables or disables the running of business rules that might normally be triggered by subsequent actions. If the e parameter is set to false, an insert/update will not be audited. Auditing only happens when the parameter is set to true for a GlideRecord operation.

 

more info for GlideRecord 

 

 

 

and

 

for a WorkflowDuration it sets the workflow schedule/timezone. Used for schedule_type workflow_schedule and timezone_type workflow_timezone).

 

More info for WorkflowDuration 

 

If my answer help you, add a star to it 😉