How to copy Additional commentd from a SCTASK to a RITM?

Jesus Nava
Tera Guru

Hello experts, please I need your help, I'm trying to use a BR to copy "Additional comments" from a SCTASK to a RITM, I searched different ideas in the community but I am having the following issue:

I'm using this code from this post:

find_real_file.png

https://community.servicenow.com/community?id=community_article&sys_id=6b26c55cdb728550dd886c8e13961928

but the issue is that when I add a comment in "Additional Comments", it gets copied over to the RITM with no problem, but the comment I add in the SCTASK gets duplicated:

find_real_file.png

Is there something I need to modify?

Thank you!

 

6 REPLIES 6

Vipul Sethi
Kilo Guru

There may be possibility that your BR is running multiple times ,check your BR filter conditions and add logging in script to see if its triggering multiple times like this

gs.log("BR is Running  :"+ current.number, "My_BR");

go to system logs search the log by applying filter  : source is "My_BR" if you see multiple logs for the same sc task transaction.

Nayan Mahato
Tera Guru

Hi Jesus,

Write a before insert and update business rule with the below code and condition when additional comments changes on the sc_task, it will work.

****************************

(function executeRule(current, previous /*null when async*/ ) {
    var taskComments = current.comments.getJournalEntry(1).split(' (Additional comments)')[1].trim();
    
    
    var ritm = new GlideRecord("sc_req_item");
    if (ritm.get(current.request_item)) {
        ritm.comments = "Comments from Task:" + "" + current.number + ":\n" +taskComments;
        
        ritm.update();
    //    ritm.setWorkflow(false);
       

    }

 

*******************************

Regards,

Nayan

Thank you Nayan, I'm having the issue that the comment still gets duplicated in the SCTASK:

find_real_file.png

Regards

Aman Kumar S
Kilo Patron

If you want to copy the additional comments one way only, from sc task to RITM:

Follow below article:

Copy additional comments from sc task to ritm

Best Regards
Aman Kumar