Alterative for Current.Update(); in After Business Rule

Admin7267
Kilo Sage

Hello,

 

There was an After Business Rule on Insert and Update when assignment group changes to 'Service Desk'. I don't want to use the current.update(); on below script.

 

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

var incCreate = new jiraUtils;
var returnData = incCreate.createIncident(current, 'Create', 'Jira-Incident');
 
if(returnData.status == '201'){
	var resp = JSON.parse(returnData.response);
	gs.addInfoMessage('Issue created successfully in JIRA with ID '+ resp.key);
	current.correlation_id = resp.key;
	current.correlation_display = resp.id;
	current.update();
}
else{
	//var body = JSON.parse(returnData.response);
	gs.addErrorMessage('Error in creation');
}
})(current, previous);
2 REPLIES 2

Peter Bodelier
Giga Sage

Hi @Admin7267 

 

If you want to use an after BR, and if you want to update the record, you will need to use current.update(), unless you query the record again, and do a gr.update() for example. This however does exactly the same.

 

You could switch to a Before BR, to be able to remove the current.update() completely.

 

In questions like this, it helps to add why you want to do something, to get a better answer.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Anand Kumar P
Giga Patron
Giga Patron

Hi @Admin7267 ,

You can use current.setWorkflow to false it will stop other business rule to run stop the recursive update.Or use Async business rule instead after business rule

current.setWorkflow(false); 
current.update();

Please mark it as solution proposed and helpful if its serves your purpose.

Thanks,

Anand