copy sctask comments to ritm

nameisnani
Mega Sage

Hi Team ,

 

can anyone please help me on this requiement .

 

Ony for particular catalog item ' Snow Support ' 

 

whenever sctask worknotes is updated the same comments should copy in ritm additinal comments . 

 

how to configure , can any one please help me .

 

@Ankur Bawiskar  Please help me here 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@nameisnani 

you can use after update business rule on sc_task

Condition: Work notes Changes && current.request_item.cat_item.name == 'Your Item Name'

Script:

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

    // Add your code here
    var ritm = current.request_item.getRefRecord();
    ritm.work_notes = current.work_notes.getJournalEntry(1);
    ritm.update();

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

12 REPLIES 12

@Ankur Bawiskar  

 

also what ever attachments we are attaching the same has to copy to ritm . that to only for this catalog item . how to do that ?

@nameisnani 

Did I answer your original question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar  

 

Could u please help me on this

@nameisnani 

I believe it's a bit unfair to ask follow-up questions without acknowledging the original response. If your initial query has been answered, it’s courteous to mark the response as correct. The discussion can then continue within the same thread for any related follow-ups.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@nameisnani 

you can use after insert business rule on sys_attachment

Condition: current.table_name == 'sc_task'

Script:

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

    // Add your code here
    var gr = new GlideRecord("sc_task");
    gr.addQuery("sys_id", current.table_sys_id);
    gr.addQuery("request_item.cat_item.name", "ServiceNow Suppor");
    gr.query();
    if (gr.next()) {
        new GlideSysAttachment().copy("sc_task", gr, 'sc_req_item', gr.request_item.sys_id);
    }

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader