Copy Worknotes from one task to another

Tadz
Tera Guru
Tera Guru

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

GChanner
Tera Guru

No updates on this as yet. Still waiting.

Hello,

Someone responded at least today, but I mean waiting 4 months and you having no success on your own?

What have you tried on your end?

Where is your question posted on the forums (your own question not piggybacking off of another thread), etc.?

Thanks...

 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

rajneeshbaranwa
Giga Guru

I believe you want to copy entire work notes of TASK1 to TASK2 when the TASK1 closes.

 

In this case , condition of business rule would be TASK1 state changes to close and script would be.

Please mark my answer correct/useful , if it helped you

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.getJournalEntry(-1);

// to disable businesss rules on this record we can use setwrokflow false

gr.setworkflow(false); 
gr.update();
}

 

 

What is -1 in current.getJournalEntry(-1);

(1) is to copy the latest comment
(-1) is to copy all the comments


***Mark Correct or Helpful if it helps.***