How to copy close notes to addition comment while closing the sc task record

VIKAS MISHRA
Tera Contributor

I am using below mentioned after update BR which is not working. basically i am able to get the value of close notes but unable to popuate it in additional comment

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

    var openedBy = current.opened_by;
    var assignmentGroup = current.assignment_group;
    if (assignmentGroup == 'e8c3483c1b118510f48c65f7b04bcb0d' || assignmentGroup == 'ed09322b1b0c4d10680a0e9cdc4bcb43' || assignmentGroup == '551536e91b22cd10680a0e9cdc4bcb6a') {
		
        var comment = current.close_notes;
		gs.addInfoMessage(comment);
        //current.comments = comment;
       current.comments  = comment;
    }



})(current, previous);
1 ACCEPTED SOLUTION

Karthiga S
Kilo Sage

Hi @VIKAS MISHRA 

 

Please use the below syntax to update comments in BR.

current.comments.setJournalEntry('Resolution:\n' + current.close_notes);

Please mark it Correct and Hit Like if you find this helpful!

 

Regards,

Karthiga

View solution in original post

3 REPLIES 3

Karthiga S
Kilo Sage

Hi @VIKAS MISHRA 

 

Please use the below syntax to update comments in BR.

current.comments.setJournalEntry('Resolution:\n' + current.close_notes);

Please mark it Correct and Hit Like if you find this helpful!

 

Regards,

Karthiga

Bert_c1
Kilo Patron

Hi Vikas,

 

I tried the following in scripts background and it worked.

 

var inc = new GlideRecord('incident');
inc.query();
while (inc.next()) {
  inc.comments = "Another new comment for incident: " + inc.number;
  var res = inc.update();
  gs.info("Updated " + inc.number + " with a new comment, result = " + res);
}

 

Is your BR defined to run "Before"? I tried a Before BR, and while the info message was displayed, the comment was not added to the record. So something else is in play here when using the incident form.  Maybe other community members will comment here.

Bert_c1
Kilo Patron

Hi,

 

Karthiga's suggestion works. Please mark that response as Accepted.