We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Copy Work Notes from SCTASK to RITM

appstorm
Tera Contributor

I have two BR running from the SCTASK table to copy work notes/ additional comments to the parent RITM.  However, none are working.

 

Below, is an example of one of the Business Rules for SCTASK>RITM.

 

- Table: SCTASK

- Before/ Update

- Condition: When Work Notes Changes

 

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

	if(current.work_notes.nil()){
		return;
	}	

	else {

		var gr = new GlideRecord('sc_req_item'); 
		gr.addQuery('sys_id',current.request_item);
		gr.query();
		while(gr.next()){
			gr.work_notes = "Work Note added from: " + current.number + " | " +current.request_item.cat_item.name + "\n >>>  " +current.work_notes;
			gr.update();
		}
	}
})(current, previous);

 

 Thoughts?

4 REPLIES 4

SAI VENKATESH
Kilo Patron

Hi @appstorm 

you can write before business rule  and use the below Script:

 

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

    // Add your code here
    var reqitem = new GlideRecord('sc_req_item');
    reqitem.addQuery('sys_id', current.document_id);
    reqitem.query();
    if (reqitem.next()) {
        reqitem.comments = reqitem.comments + "\n" + current.comments.getJournalEntry(-1); 
        reqitem.update(); 
    }

})(current, previous);

 

 Thanks and Regards

Sai Venkatesh

Thank you for the suggestion!  I tried the code, above - changing comments to work_notes.  However, still nothing.  Does this need to be a 'Before' Update or 'After'?

Hi @appstorm 

Can you try it with before insert or update

'Before' also doesn't work.  I also double-checked no other business rules are running that may be conflicting with these two.