UI Action Not Working In One Specific Scenario

Casey23
Tera Guru

Hello All,

 

As the subject says, we have a UI action that is not working in one specific scenario. This UI action is utilized across all TASK records in order to close a task. It hasn't been updated since 2017, which is important to note because the UI action works everywhere else and so I don't want to change it. I'm just trying to understand why it won't work in this one scenario.

 

In this scenario, a request is submitted from the catalog, approved by a manager and then the RITM and TASK from the workflow is created. Because another team is sometimes needed to be involved in this request, a manual task is being created for the other team at the RITM level. Once that team member wants to close their TASK, they are unable to. They click the "Close Task" UI action, a couple of the fields are set to read only, but the state doesn't actually change and the record isn't updated. No errors on the page or in the browser console. 

 

If I submit a different request from the catalog and go through the same process to create a manual TASK for that team, I am able to close the manual TASK successfully with the same UI action. If I compare this now successfully closed task against the one I mentioned in the above paragraph, I don't see any major differences that stick out to me as being a problem with the UI action since the conditions are minimal and appear to match between the TASKs.

 

The script being executed in the UI action is as follows:

function mihsCloseSCTask() {
    var preValue = g_form.getValue('state');
	g_form.setValue('state', 3);
	//Call the UI Action and skip the 'onclick' function
// 	gsftSubmit(null, g_form.getFormElement(), 'mihs_close_sc_task');	
	var isSuccess = gsftSubmit(null, g_form.getFormElement(), 'mihs_close_sc_task');
	if(!isSuccess)
		{
			g_form.setValue('state',preValue);
		}
}

//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
	mihsUpdateSCTaskServer();

function mihsUpdateSCTaskServer() {

	current.state = 3;
	current.update();
}

 

Here is an image of the UI action:

2023-06-12 14_09_50-Window.png

 

Again, I confirmed the state is < 3 and that the approval is not equal to requested in both TASK types before clicking the UI action, yet the UI action is only failing for one of them. What else can I check on this to see why it isn't working?

1 ACCEPTED SOLUTION

Casey23
Tera Guru

It turns out that the issue was with an onSubmit client script, which makes a lot of sense considering that it was tied to a catalog item and that catalog item was the only one with this issue. There was a logic issue and because that task didn't meet the conditions in the onSubmit script, the script was returning false and not allowing the task to be submitted. Correcting the client script now allows for the task to be closed successfully.

View solution in original post

11 REPLIES 11

Ankur Bawiskar
Tera Patron
Tera Patron

@Casey23 

Did you try adding logs and alert in that UI action?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

No. The UI action itself is functioning as expected, just not for this one scenario. As others are suggesting, I don't believe the issue is in the UI action.

@Casey23 

what debugging have you done so far?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

So far I've enabled debugging and validated that there weren't any errors when the UI action is clicked. I also looked at business rules in the task/sc_task tables to find rules that have setAbortAction in the script, per jaheerhattiwale's request, but didn't see any. There are many in the system that do, but not on those two tables.