Copy additional comments from sc task to ritm on SP

John Vo1
Tera Guru

Has anyone created a business rule that will copy the sc task comments to RITM in SP view?

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi John,

 

You need use write a before Update Business rule on Catalog Task table with condition as Additional comments changes which will copy comments to RITM. Something as below should help.

If it is worknotes you using then replace comments in code below with work_notes.

(function executeRule(current, previous /*null when async*/) 
{
var com = "Catalog Task Comments for " + current.number + " : " + current.comments;
var v_gRITM = new GlideRecord('sc_req_item');
v_gRITM.addQuery('sys_id', current.request_item);
v_gRITM.query();
if (v_gRITM.next()) 
{
v_gRITM.comments= "Catalog Task Comments for " + current.number + " : " + current.comments;
v_gRITM.update();
}
})(current, previous);

View solution in original post

6 REPLIES 6

Write a before insert and update business rule with the below code and condition when additional comments changes on the sc_task, it will work.

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

(function executeRule(current, previous /*null when async*/ ) {
    var taskComments = current.comments.getJournalEntry(1).split(' (Additional comments)')[1].trim();
    
    
    var ritm = new GlideRecord("sc_req_item");
    if (ritm.get(current.request_item)) {
        ritm.comments = "Comments from Task:" + "" + current.number + ":\n" +taskComments;
        
        ritm.update();
    //    ritm.setWorkflow(false);
       

    }

 

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

Regards,

Nayan

Hello @Jaspal Singh 

If i need to both additional comments and work notes how can i write this

and in the comments instead of this i need short description of the task 

"Catalog Task Comments for " + current.number