Calling gsftsubmit in onsubmit client script to trigger UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2020 09:02 AM
Hi there,
We are trying to use the Resolve Incident UI action in the service portal form page. Through some research i understand that the UI Actions that have "Client" field checked will not be avaialble on Service Portal. But we have few client side validations on the UI action to be performed before executing the server side code. If we Uncheck "Client" field, the validation script won't work.
For that i have created a client script and moved the client side validation script there. Once validation is through, i am calling UI action through "gsftsubmit" action.
This is working fine in the service portal. But if i use the Resolve Incident UI action in native servicenow app, the client script is going into loop and never comeback. I am not sure what wrong i am doing here. Below is the client script that we have written.
Can somebody, please let me know if i am doing anything wrong here. Or please suggest if there is another way to achieve this functionality.
Thanks,
Venu
function onSubmit() {
//Type appropriate comment here, and begin script below
alert(g_form.getActionName());
if(g_form.getActionName() == 'resolve_incident')
{
var tfsid = g_scratchpad.tfsid;
var tfsStatus = g_scratchpad.tfsstatus;
var company = g_scratchpad.companyID;
g_form.clearMessages();
var incidentNumber = g_form.getValue('number');
if (g_form.getValue('close_notes') == '') {
try {g_form.hideFieldMsg('close_notes');} catch(e) {}
g_form.setMandatory('close_notes', true);
g_form.addErrorMessage("Resolve Notes on the Closure tab are required when resolving an Incident.");
g_form.showFieldMsg('close_notes','Resolve Code and Notes are required when resolving an Incident','error');
return false;
}
gsftSubmit(null, g_form.getFormElement(), 'resolve_incident');
}
}
- Labels:
-
Scripting and Coding
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2020 09:20 AM
Hi,
Your catch is just open and closed?
try {g_form.hideFieldMsg('close_notes');} catch(e) {}
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2020 03:02 AM
I have to admit, I'm a little unsure why this seems to work in the ServicePortal, but it would seem like the fact that gsftSubmit(null, g_form.getFormElement(), 'resolve_incident'); ends up triggering your onSubmit script over and over is the issue. One possible solution would be to perhaps set your onSubmit script to have UI Type of Mobile / Service Portal only? That seemed to work for me - the resolve button still resolved the incident but didn't trigger the endless loop in the UI.
If this was helpful or correct, please be kind and remember to click appropriately! Michael Jones - Proud member of the CloudPires team!/p>
Michael D. Jones
Proud member of the GlideFast Consulting Team!