UI action not being triggered
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 02:28 PM
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);
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 08:32 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2022 07:45 AM
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!