Copy RITM Worknotes to SCTASK - ServiceNow Support

nameisnani
Mega Sage

Hi Team ,

 

I have to whcih ever we have updated in additonal comments the same should be copied in sctask worknotes only a particular catalog item 

 

I have configured After update BR for 

 

nameisnani_0-1752643152554.png

nameisnani_1-1752643177493.png

 

 

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

    var latestComment = current.comments.getJournalEntry(1); // get latest additional comment

    var taskGr = new GlideRecord('sc_task');
    taskGr.addQuery('request_item', current.sys_id);
    taskGr.query();
    while (taskGr.next()) {
        taskGr.work_notes = "Customer Comment from RITM:\n" + latestComment;
        taskGr.update();
    }

})();

 

Test Reults -

 

nameisnani_2-1752643276730.png

nameisnani_3-1752643308805.png

 

 

comments were not copied ritm to sctask 

 

can any one please help me what was the mistake here .

 

@Ankur Bawiskar  could you pllease help me here on my mistake 

7 REPLIES 7

Di Zhang
Tera Guru

Did you check activity stream in sctask? 

@Di Zhang 

 

how should i check

Chaitanya ILCR
Kilo Patron

HI @nameisnani ,

 

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

	// Add your code here
	var latestComment = current.comments.getJournalEntry(1); // get latest additional comment

    var taskGr = new GlideRecord('sc_task');
    taskGr.addQuery('request_item', current.sys_id);
    taskGr.query();
    while (taskGr.next()) {
        taskGr.work_notes = "Customer Comment from RITM:\n" + latestComment;
        taskGr.update();
    }

})(current, previous);

you are missing the current and previous parameters in the last line

 

replace the entire script with the shared script

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

Hi @nameisnani ,

 

Have you had a chance to review my response?

 

If you find it helpful could you please give a like and accept it as a solution and close the thread 

 

Thanks 

Chaitanya