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

Try this code and business rule to run on 'Display'.

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

// Add your code here
var request =current.request.getRefRecord();


request.u_summary = current.variables.Summary;


//request.update();
})(current, previous);

 

Unfortunly it doesnt work either still field empty.. 

 

Is it possible to add the req.close_notes field to SC_task form and update it from there ? I tried it, but i cannot make an acl work to make it editable from task form. 

 

Anyhow the BR still doesnt work for us..

Rick58
Tera Contributor

Hi Jay Jay,

You won't be able to dot-walk from the parent REQ to a child task, but you could use a business rule on RITM and dot-walk to the REQ close_notes.

I might do something like this:

I found a way to do this by first copying the close notes from task to request item and then to copy from request item to request.

This works for me. 

1. Write a business on sc_task

find_real_file.png

find_real_file.png

2. Write a business rule on sc_req_item

find_real_file.png

find_real_file.png

If you would like to copy the close notes only when it is not empty. Add below condition.