Move Catalog task worknotes to RITM worknotes?

Kris V
Kilo Guru

I have found a bunch of articles for pushing catalog task work notes to the RITM work notes, but none are quite what I am looking for.

I need to push the task work notes to the RITM work notes but only for one catalog item, not all. I am not sure if I need a business rule for this, or if I can just use a run script in the workflow to push those notes?

I have tried both ways but have been unsuccessful so far.

Here is the business rule I attempted, if anyone could help out it would be much appreciated:

When to run: After Insert, Update

condition: current.work_notes.changes()

Table: sc_task

Script:

(function executeRule(current, previous /*null when async*/) {

var item = new GlideRecord('sc_req_item');
item.get(current.request_item);

if (item == '3c8f73a7db669f04dc05546adc96194b'){
item.work_notes = current.work_notes;
item.update();

}

})(current, previous);

 

1 ACCEPTED SOLUTION

Yes, if condition is not required and here is the updated code.

 

(function executeRule(current, previous /*null when async*/) {

var item = new GlideRecord('sc_req_item');
item.get(current.request_item);
item.work_notes = current.work_notes.getJournalEntry(1); //Get last journal entry
item.update();

})(current, previous);

View solution in original post

13 REPLIES 13

Hello Pradeep,

 

I missed that field name !! Thank you for pointing. 

then below script should work.

 

(function executeRule(current, previous /*null when async*/) {

gs.log("inside","updateBR");

var item = new GlideRecord('sc_req_item');
item.get(current.request_item);
gs.log("inside 2","updateBR");
if (item.cat_item == '3c8f73a7db669f04dc05546adc96194b'){

gs.log("inside 3","updateBR");
item.work_notes = current.getDisplayValue('work_notes');
item.update();

}

 

Thanks,

Ali

})(current, previous);

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Ahmmed, 

 

This works, but it gets all of the work notes every time, this was helpful, but Pradeeps answer is what I am trying to use, as it just puts the last work notes entry in the RITM work notes. 

 

Thanks you for the responses!

Hello,

 

if you want to copy latest work notes, then try below statement in BR.

item.work_notes = current.work_notes.getJournalEntry(1);

 

as Pradeep suggested better to have item condition in business rule when to run condition builder. above statement would copy latest entry in the work notes field.

 

Thanks,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Hi @krisv,

 

You are very welcome. Let me know if that answered your question. If so, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

 

-Pradeep Sharma