What is the correct way to use current.setAbortAction(true)?

bradfournier
Kilo Expert

I have a business rule in which I'm attempting to use current.setActionAbort(true), but it doesn't seem to be working as I would expect. The BR runs onBefore Update to check and see if the current record has any open subtasks. If there are open subtasks, it should stop the update of the record, and display an info message at the top of the screen. In it's current form, it does stop the record from being updated, however it reloads the page with the same field changes still displayed, and it does not show the Info message at the top of the record. I'm wondering if I'm using the 'current.setAbortAction(true)' incorrectly, or if I'm not understanding how it works in general. Any help is appreciated! Code is below:

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

	var tsk = new GlideRecord('task');
	tsk.addQuery('u_parent_task',current.sys_id);
	tsk.addQuery('active',true);
	tsk.query();
	if(tsk.getRowCount() > 0) {
		gs.addInfoMessage('Please close all subtasks to close the request');
		current.setAbortAction(true);
	}

})(current, previous);
13 REPLIES 13

Jaspal Singh
Mega Patron
Mega Patron

Hi Brad,

 

Can you confirm once on which table (parent or subtask) is the Business rule being written.

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

The business rule is running on the table of the parent task.

Hi Brad,

 

Try using below code on Parent table that runs on Update

 

var activeTask = new GlideRecord('sub_task_table'_name);
activeTask.addQuery('active',true);
activeTask.addQuery('parent', current.sys_id);
activeTask.query();
if (activeTask.next()) {
gs.addErrorMessage('Please close all subtasks to close the request');
current.setAbortAction(true);
}

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

Hi Jaspal,

I tried this code, however the result is the same as before.

 

Thanks,

Brad

payal13
Kilo Contributor

I am facing exactly same issue today. Any help is appreciated.