How to update the additional comments of SCTASK table on RITM table additional comments.

akchauhan
Tera Contributor

As SCTASK table is not visible to end user, emails cannot be triggered from there to them and our customer do not like to move between SCTASK and RITM table in order to interact with end user. So we thought of mapping the SCTASK table additional comments on RITM table additional  moments so that email can be triggered to end user or task assigned to accordingly. How to achieve this functionality.

1 ACCEPTED SOLUTION

Hi @akchauhan ,


Try this:
Table: sc_task
When: after
Condition: Comments changes
Insert: true
Update: true

    // Get the latest comment from the task

    var latestComment = current.comments.getJournalEntry(1); // 1 = most recent pass 1 in parenthesis

    // Get the associated Request Item (RITM)

    var ritmGR = new GlideRecord('sc_req_item');

    if (ritmGR.get(current.request_item)) {

        // Add the comment to the RITM's Additional Comments

        ritmGR.comments = "Comments added on task :" + current.number + "\n" + latestComment;

        ritmGR.update();

    }

 

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@akchauhan 

this after update BR on sc_task when Comments Changes will work for you

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

    // Add your code here
    var comment = current.comments.getJournalEntry(1); // get latest comments
    var ritm = current.request_item.getRefRecord();
    ritm.comment = "Catalog Task Comments for " + current.number + " : " + comment;
    ritm.update();

})(current, previous);

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

akchauhan
Tera Contributor

Dear Anand,

I have one more query, if you can help in any way that would be  highly appreciable.

Dear Team,

On the incident form, next to short description we have knowledge search option basis the short description of that incident . But in my prod instance, that search is not working. When I am removing the short description from the search bar . I am able to see 600 approved published KB articles but when I am searching anything then it is not working. Same functionality is working fine I'm dev and test instance. Please assist . I am zurich release and no upgrade has been done till now.