How to write a BR that copies close notes from task to request?

Jay Jay
Giga Expert

I have had some trouble making an BR that copies close notes from SC Task to request table (preferly it only adds info and not delete if field allready has txt in it )... Problem is i dont see what the error is...

 

Please check screenshots

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

You should be able to do this with a single 'After' 'Update' business rule on the 'sc_task' table.  The business rule should run when the Close notes field changes and the Close notes field is not empty.  Here is the script...

(function executeRule(current, previous /*null when async*/) {
	// Query for the Request parent
	var req = new GlideRecord('sc_request');
	req.addQuery('sys_id', current.request_item.request);
	req.query();
	if (req.next()) {
		// Add current close notes to request close notes
		req.close_notes = req.close_notes + '\n' + 'Close notes added from ' + current.number + ':\n' + current.close_notes + '\n';
		req.update();
	}
})(current, previous);

View solution in original post

12 REPLIES 12

sachin_namjoshi
Kilo Patron
Kilo Patron

Create an after business rule on sc_task table

 

 

When: after insert and update

 

Conditions: Additional comments changes
Script:

 

var gr= new GlideRecord("sc_req_item");

 

gr.get(current.getValue("request_item"));

 

gr.<field name on request item>=current.comments.getJournalEntry(1);

 

gr.update();

 

 

Could you write it a bit more specific ? Its not from RITM table and its not additional comments but close notes from task to request?

Surya66
Mega Guru

find_real_file.pngfind_real_file.png

 

 

 

Thanks alot for the reply. I tried the above rule but somehow nothing happens. WHen I try to debug i see that it runs rule  "

business rule07:53:29.380: Global       ==> 'Copy Close notes task to Request' on sc_request:REQ0017901
business rule07:53:29.382: Global       <== 'Copy Close notes task to Request' on sc_request:REQ0017901"
 
But no data is added to the field on request form, how do i try to solve the error ?