Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

UI action not being triggered

Ulrich Matthew
Tera Contributor

 

I have this Client script that calls a UI page or a sp modal depending if you're working in the backend or portal

but  it's not calling the UI action 

function onSubmit() {
	var conf;
	if (g_form.getActionName() == 'approve_new_employee') {
		conf = confirm('Please confirm account New Employee Approval');
		return conf; // Updates the database if confirmed, aborts if canceled
	} else if (g_form.getActionName() == 'terminate_employee') {
		var c = this;

		/**/
		if (window === null) {

			var dialog = new GlideDialogWindow('show_termination_reason');
			dialog.setTitle('Resolve');
			dialog.render();
			return false;


		} else {
			spModal.open({
				widget: 'terminate_employees',
				buttons: 'false'
			}

						).then(function(reason) {
				c.reason = reason;
			});
		}


		return false;
	} else
		return true;

}
if(gs.hasRole('u_itechag.base_hr_manager_lead')) {

	//If HR Manager, terminate employee with no approval
	current.u_work_status = 'Terminated';	
} else {
	current.u_work_status = 'Terminating';
}
current.update();
action.setRedirectURL(current);

 

 

2 REPLIES 2

-O-
Kilo Patron

There is no code in the script that would call UI Actions. In order to re-trigger a UI Action you should be calling gsftSubmit(null, g_form.getFormElement(), '<UI Action action name>') in Platform UI and g_form.submit('<UI Action action name>') in Portal. However doing that would just trigger the onSubmit again. So you would need to come up with a mechanism to signal to the onSubmit script that the action has been confirmed and it is OK to go on. I would create separate Client Scripts for Platform UI and Portal/Mobile. It's safer and easier than checking for windows.

Allen Andreas
Tera Patron

Duplicate post: https://community.servicenow.com/community?id=community_question&sys_id=1cf3b315db3c5910b5d6e6be1396...


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!