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

Anand2799
Tera Guru

Hi @akchauhan ,

 

Refer the below thread:

Solved: Copy comments from RITM to Task & vice versa. - ServiceNow Community

 

If this solves your query, mark this as correct/helpful.

 

Thanks

Anand

Hello Anand,

Solution is not working. If you can assist in any way, Please assist.

akchauhan_0-1761878588115.pngakchauhan_1-1761878614708.png

 

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();

    }

 

akchauhan
Tera Contributor

Dear Anand,

Many thanks for such quick support on my query. I am able to see the mapping between SCTASK and RITM table and comments are copying. Many many thanks for your support.