snow_beginner
Giga Guru

Hi @Mark Manders here is the code for the UI action below:

 

on Click: resolveIncident();

 

condition: (current.incident_state != IncidentState.CLOSED && current.incident_state != IncidentState.RESOLVED && current.incident_state != IncidentState.CANCELED) && (gs.hasRole("itil") || gs.hasRole("itil_admin") || current.caller_id == gs.getUserID())

 

script:

function resolveIncident(){
	//Set the 'Incident state' and 'State' values to 'Resolved', and display mandatory fields
	g_form.setValue('incident_state', 6);
	g_form.setValue('state', 6);
	g_form.setValue('resolved_by', g_user.userID);
	
	gsftSubmit(null, g_form.getFormElement(), 'resolve_inc'); //MUST call the 'Action name' set in this UI Action
}

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

function serverResolve(){
	
	//checkOpenTasks();
	current.incident_state = IncidentState.RESOLVED;
	current.update();
	current.resolved_by = gs.getUserID();
}

function checkOpenTasks() {
	var grIncidentTask = new GlideRecord('incident_task');
	grIncidentTask.addActiveQuery();
	grIncidentTask.addQuery('parent',current.sys_id);
	grIncidentTask.query();
	if (grIncidentTask.hasNext()) {
	
		current.setAbortAction(true);
		gs.addErrorMessage('All Incident Tasks must be closed before an Incident can be resolved');
		action.setRedirectURL(current);
		
		
	}
}

 

the workspace form button is unchecked and there is no script there but somehow the UI is still showing on the workspace. 

 

The OOB UI action with the workspace form button checked is disabled.