Copy additional comments from RITM task to catalog task.

PriyaRaj
Tera Contributor

Hi,

I am having a requirement. When the requester or user is updating the additional comments on RITM task then it should get copied to catalog task. Also, if the comments or work notes are updated by system then it should not copy.

It should copy only when the user is updating. Can anyone help to achieve this? 

3 REPLIES 3

Harish KM
Kilo Patron
Kilo Patron

Hi you can have a BR after update on RITM and 

Condition :

UpdatedBy doesnot contain system and

additional comment changes

 

Script:

var task = new GlideRecord('sc_task');
    task.addQuery('request_item',current.sys_id);
    task.query();
    while(task.next())
        {
            task.comments = current.comments.getJournalEntry(1);
            task.update();
        }

Regards
Harish

Chandu Telu
Tera Guru
Tera Guru

Hi 

Check the below link it's have your answer

https://community.servicenow.com/community?id=community_question&sys_id=0de670a31b3fd054d2ccea89bd4bcb4d

https://community.servicenow.com/community?id=community_question&sys_id=ae701de9dba42b001cd8a345ca961981

Thanks
Chandu Telu
Please Mark ✅ Correct/helpful, if applicable,

Vaishnavi Lathk
Mega Sage
Mega Sage

Hi,

Never use before Business rule to update or insert in such scenarios.

Since you want to update another table i.e. sc_task when RITM comments gets updated you should always use After update BR

BR: Condition

Additional Comments Changes

Script:

use below script to copy the latest comments from RITM to SC Task

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

	var sctask = new GlideRecord('sc_task');
	sctask.addQuery('request_item', current.sys_id);
	sctask.query();
	while(sctask.next()) {
		sctask.comments = current.comments.getJournalEntry(1);
		sctask.update();
	}
})(current, previous);

Regards
Vaishnavi