additional comments on task

Shir Sharvit
Tera Contributor

Hi,

How can I automatically copy additional comments from the support task to the associated request item when the supporter (assigned to) adds an additional comment?

 

Thank.Shir

6 REPLIES 6

Samaksh Wani
Giga Sage
Giga Sage

Hello @Shir Sharvit 

 

When: after insert and update


Conditions: Assigned to Supporter
Script:

var gr= new GlideRecord("sc_task");
gr.get(current.getValue("request_item"));
gr.<field name on request item>=current.comments.getJournalEntry(1);
gr.update();

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Shir Sharvit ,

 

You can create after update Business Rule n try this script.

 

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

    // Check if comments field has been updated

    if (current.comments.changes()) {

        // Get the associated Request Item

        var requestItem = new GlideRecord('sc_req_item');

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

            // Copy additional comments from Support Task to Request Item

            requestItem.comments = current.comments.getJournalEntry(-1); // Copy the last comment

            requestItem.update();

        }

    }

})(current,

previous);

 

Thanks,

Danish

 

SANDEEP28
Mega Sage

@Shir Sharvit You can create async business rule as its going to be related record update.

 

SANDEEP28_0-1699198019002.png

 

SANDEEP28_1-1699198081945.png

 

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

    var grReqItem = new GlideRecord('sc_req_item');
    if (grReqItem.get(current.request_item)) {
        grReqItem.comments = current.comments.getJournalEntry(1);
        grReqItem.update();
    }

})(current, previous);

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

 

 

 

 

@Shir Sharvit  If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!