What is the use of setWorkflow(false)

ishankaggarwal
Tera Contributor

What is the use of setWorkflow(false)

7 REPLIES 7

Gaurav Bajaj
Kilo Sage

Hi,



Once you place it in your code before the update or insert query, this will make sure that none of the Business rule written on your table will run.


Please refer the link for more details.



GlideRecord - Scoped



Thanks


Gaurav


SanjivMeher
Kilo Patron
Kilo Patron

Check 4. Use setWorkflow(false) and autoSysFields(false) in below thread



When you are mass updating records with a background script, sometimes you don't want to run the business rules/workflow on every record you updated or have your name and the last updated time be when you updated it


Background Scripts — ServiceNow Elite



Please mark this response as correct or helpful if it assisted you with your question.

Swarup Patra
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. - This method is particularly useful when you want to make changes to a record in a controlled manner, without invoking additional processes. - It is used in GlideRecord queries. For example, if you have a GlideRecord 'gr', you can use gr.setWorkflow(false) before gr.update(). - It is important to note that using setWorkflow(false) only applies to the current server-side script in which it is used. It does not globally turn off workflows. - It is also important to use this method judiciously, as it can lead to data inconsistencies if business rules are bypassed that are necessary for maintaining data integrity. nowKB.com

Harish Bainsla
Kilo Patron
Kilo Patron

Hi 

In ServiceNow, the setWorkflow(false) method is used to disable the execution of business rules, workflows, and any other automatic processes during a GlideRecord update. It essentially allows you to perform updates on a record without triggering any associated workflows or business rules.

https://youtu.be/MdNPlarjwmU?si=SVcsSLjQ2k0UicvT

Servicenow GlideRecord AutoSysFields=false setworkflow=false || Deep analysis and explained #howto #workassignment #learningcoding #coding #servicenow #hiring #jobs #jobsearch #jobvacancy #jobvacancies #google #accenture #itjobs #salesforce #ibmjobs #oflatest #sapiens #hcl #techmahindra #cognizant