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

eroth
Kilo Contributor

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();

      }

}

13 REPLIES 13

Mike Allen
Mega Sage

You could write it directly to the sys_journal_field table.


Hi I know this is extremely old thread, but I have a very similar issue that the Original is referring to. How would you fix the following script to write the contents of the "u_comments" field to the sys_journal_field table? 

var gr = new GlideRecord("time_card");
gr.addQuery("task", "e2e2f4aa4f6fef4063bc4b5e0210c759");
gr.setLimit(1);
gr.setWorkflow(false);
gr.autoSysFields(false);
gr.query();

while (gr.next()) {
var comment = gr.getValue("u_comments");
/*gr.setValue("notes", "comment");*/
gs.log(comment);
gr.notes = comment;

gr.update();
}

yogesh15dd
Tera Guru

Hi Eric,



I have come across the similar issue now, i use the below two before using update(), function, it does not update the work notes.



//rec.setWorkflow(false);   //IMPORTANT: ensures the impending update does not trigger business rules  


//rec.autoSysFields(false);   // IMPORTANT:   ensures the impending update does not modify updated date, updated by, or update count.  



Were you able to solve this issue?



Regards


Yoigsh


Gurpreet07
Mega Sage

Hi Eric,



Please proceed as Mark specified ... The reason being , data from these journal fields copied to sys_journal_field table using some Business Rule at backend. When you set workflow to false , that BR get Skipped as well.