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

Hari Krishna1
Tera Contributor

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
Tera Patron

Hi @Hari Krishna1 

 

Might be helpful

 

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

 

@Jaspal Singh 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

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/atul_grover_lng [ Connect for 1-1 Session]

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

Anubhav24
Mega Sage
Mega Sage

Hi @Hari Krishna1 ,

 

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.