Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Copy Worknotes from one task to another

Tadz
Kilo Sage

Hi Everyone,

I have this requirement where I have two catalog task in which when 1 task updated their worknotes it should reflect to the other task.

The issue is, since they are on the same table sc_task. Whenever i tried to do a gliderecord and update it will reflect back to the current updated record. Causing it to be duplicated.

My Approach is an On Before Business Rule.

with the following script:

var gr = new GlideRecord("sc_task");
gr.addQuery("request_item", current.request_item);
gr.addQuery("number", "!=", current.number);
gr.query();
if (gr.next()) {
gr.work_notes = current.work_notes;
gr.update();
}

 

Is there a way to update without causing the current record to be updated again? I already tried setworkflow(false) but its not working.

 

Thanks in advance! 

Tadz

14 REPLIES 14

Harsh Vardhan
Giga Patron

use after business rule

 

adding thread here. please refer that.

 

https://community.servicenow.com/community?id=community_question&sys_id=a6df211cdbe42b40f7fca851ca96...

Harsh Vardhan
Giga Patron
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.request_item);
gr.addQuery('sys_id','!=',current.sys_id);
gr.orderByDesc('number');

gr.query();

while(gr.next())

{
gr.work_notes = current.work_notes;
gr.update();
}

 

Note: use After Business rule and set the condition worknotes changes

Bhojraj Dhakate
Tera Expert

Hi TADZ,

Update code with following function:

var gr = new GlideRecord("sc_task");
gr.addQuery("request_item", current.request_item);
gr.addQuery("number", "!=", current.number); 
gr.query();
if (gr.next()) {
gr.work_notes = current.work_notes; //Update code with gr.work_notes=current.getJournalEntry(1);
gr.update();
}

 

Thanks,

Bhojraj

I tried but it does not working.
I believe it should be current.work_notes.getJournalEntry(1);