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

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi,

 

Updated code below.

 

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

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

if (item.cat_item == '3c8f73a7db669f04dc05546adc96194b'){

item.work_notes = current.work_notes;
item.update();

}

})(current, previous);

 

I would recommend having filter conditions in the BR i.e Requested Item->Item | is | CATALOG ITEM NAME. This way the BR will only trigger for that respective item. 

 

-Pradeep Sharma

Pradeep, 

 

Thanks for the reply. 

 

I changed the BR to the code above, and also set the condition as you suggested, but it is still not working. Since I changed the condition should I remove this part since the condition is already doing that for me? 

if (item.cat_item == '3c8f73a7db669f04dc05546adc96194b')

 

Here is what I have now:

find_real_file.png

find_real_file.png

I tried removing the if statement and that didn't work, I also added the condition Work Notes Changes and still not pushing the task work notes to the RITM work notes. 

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