What is the use of setWorkFlow(false)? Scoped GlideRecord - setWorkflow(Boolean enable) Enables or disables the running of business rules, script engines, and audit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2018 07:13 AM
If setWorkFlow(false) disable all business rule run after it. Then why we create those business rule which runs after it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2018 05:22 PM
setWorkFlow(false) basically helps you when you are doing some data changes.
Example:
By default duration field on task is empty and not calculated when task is closed. If want to update that field with actual duration I'll do below;
That way I updated all tasks but didn't fire any business rule.
var gr = new GlideRecord("task");
gr.addEncodedQuery('active=false^calendar_durationISEMPTY');
gr.autoSysFields(false); // so that the records don't have system updates
gr.query();
while(gr.next()) {
var gdt1 = new GlideDateTime(gr.sys_created_on.getDisplayValue());
var gdt2 = new GlideDateTime(gr.closed_at.getDisplayValue());
var dur = gs.calDateDiff(gdt1, gdt2, false);
gr.calendar_duration = dur;
gr.setWorkflow(false);
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2020 03:41 AM
work note not updating after setting workflow false
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2020 05:02 AM
Hi dkboss,
Field changes wont be audited, if we use the parameter as "false".
By default, for all the business rules it will be "setWorkFlow(true)", when we use the false, no field changes or. work notes will be seen under Activity logs.
Click Helpful, if i was able to fulfill the answer.
Thanks,
Arjun.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2020 02:36 AM
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.
Regards
Sumedh Kharode
www.dxsherpa.com