Trying to use setWorkflow(false) and update work_notes this does not seem to allow journal fields to be updated when false string fields seem to work ok. Does anyone know how to update work_notes without causing BR to fire
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2015 12:02 PM
UpdateTasks();
function UpdateTasks() {
if (current.sys_id == '') {
return;
}
gs.log('Current user ID 1');
var tasks = new GlideRecord('sc_task');
tasks.addQuery('parent', current.sys_id);
tasks.query();
while (tasks.next()) {
gs.log('Current user ID 2' + current.comments);
tasks.close_notes = '8989890';
tasks.work_notes = '12345';
tasks.setWorkflow(false);
tasks.update();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2016 06:26 AM
Hi Gurupreet,
In order to avoid this issue, m giving the 'setworkflow' method after the update() activity like below, i think that's how it should be, but not sure.
inc.update();
inc.setWorkflow(false); //IMPORTANT: ensures the impending update does not trigger business rules
inc.autoSysFields(false); // IMPORTANT: ensures the impending update does not modify updated date, updated by, or update count.
What i think is, if i make the workflow false immediately after update, as you explained, it will not trigger the backend business rule once again, which is used to carry the data from these journal fields to sys_journal_field table.
could you confirm is this fine?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2016 06:35 AM
Hi Yogesh,
In above case when the script is executed, corresponding BR on target table will not be fired
i.e setWorkflow(false); will disable firing of BR on target table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2016 06:42 AM
Thanks Pradeep.
is it fine to give it after update() method, like below? or after BR's will be triggered on the target table before the code reaches setworkflow(false) code in the below snippet?
inc.update();
inc.setWorkflow(false);
inc.autoSysFields(false);
i think this helps only to stop the after BR's if it works. before BR's will anyways be triggered on the target table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2016 06:48 AM
Don't know it will work or not ... Ideally it shouldn't work because ... when update statement execute , by default setWorkflow is true and it will trigger the Business Rules and setWorkflow(false) in later statements should not make any difference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2016 06:54 AM