setWorkFlow() use?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 10:05 PM
can anyone please help me to understand about setworkflow(false) this function with example.
- Labels:
-
Workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 10:10 PM
Hi please find below
setWorkflow()
The serWorkflow() method accepts one argument: a boolean true/false value. This argument will determine whether business rules should be triggered by any database actions performed by your GlideRecord script. For example, if you make a change and call the update() method, calling setWorkflow() and passing in false will prevent any business rules that would normally be triggered by that update from running.
‘setWorkflow’ is used to enable/disable the running of any business rules that may be triggered by a particular update.
var gr = new GlideRecord('incident');
gr.addQuery('category', 'software');
gr.query();
while(gr.next()){
gr.category = 'hardware';
gr.setWorkflow(false);// this will ensure that there will be no business rule update for this update.
gr.update();
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2023 08:35 AM
Any idea on how to prevent this from being used in the system ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 10:11 PM
If you trying to modify/create a record in Servicenow using GlideRecord. It may happen that there are some business rules that are written for that modification or on insert of a record.
For example, You are changing the state of incident to In Progress using GlideRecord. And there is business rule which has a condition that state changes to In Progress. So when you run your script that business rule will also run. There might be many other things also configured like workflow, notifications etc on that condition.
SO if you do not want your code changes to trigger any other code like Business Rule, Workflow etc
use setWorkflow(false). This will make sure no other scripts are fired due to the changes your script is doing