We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

To automatically populate comments from Request Item Table to Request Task Table and viceversa

Not applicable

To automatically populate comments from Request Item Table to Request Task Table and vice versa , when ever comments are updated  for this I written Two Before BR in RITM and Catalog Task table .

but im getting duplicate comments also(one comment repeating two times)

 

HariKrishna1_0-1709724457462.png

 

 

 

 

Experts please help me out in this, Thanks in Advance

2 REPLIES 2

Dr Atul G- LNG
Tera Patron

Hi @Community Alums 

 

Might be helpful

 

https://www.servicenow.com/community/developer-forum/copy-comments-from-ritm-to-task-vice-versa/m-p/...

 

@Jaspal Singh 

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

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

Anubhav24
Mega Sage

Hi @Community Alums ,

 

You can try below code, you can write it in your BR , BR is created on SC_TASK table and when ever the comment changes it copies it to SC_REQ_ITEM table and similarly you can write for the other way round:

if (current.comments.changes()){
 
        var gr = new GlideRecord('sc_req_item');
        gr.addQuery('sys_id', current.request_item);
        gr.query();
        while(gr.next()) {
    var lastComment = current.comments.getJournalEntry(1);
gr.comments = current.number + " | "  + lastComment.substr(lastComment.indexOf('\n') + 1).trimRight('\n\n');    //text_value;
    gr.update();
}
    }
 
Please mark correct/helpful if my response helped you.