- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2019 03:40 PM
UI Action for Resolve Incident button on Incident form.
As a default on the instance, We could see UI Action for Resolve Incident button has same scripts on both server and client side. why is it so?
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_incident'); //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(){
current.incident_state = IncidentState.RESOLVED;
current.state = IncidentState.RESOLVED;
current.resolved_by = gs.getUserID();
current.update();
}
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2019 06:57 PM
Hey,
The reason is simple . When you set the value in Client side , it sets it on the browser but then you have to click on something to set those values in the actual database. In this case , it is setting the resolved values in the client side as well as making sure that the server values are also updated by the server side.
Once that is done, there might be additional business rules or other server side code to disable all the fields when they hit current.update().
Hope this helps you. If YES, please mark this answer as correct/helpful and close the thread.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2019 06:57 PM
Hey,
The reason is simple . When you set the value in Client side , it sets it on the browser but then you have to click on something to set those values in the actual database. In this case , it is setting the resolved values in the client side as well as making sure that the server values are also updated by the server side.
Once that is done, there might be additional business rules or other server side code to disable all the fields when they hit current.update().
Hope this helps you. If YES, please mark this answer as correct/helpful and close the thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2020 10:09 AM
Hi,
In Resolve UI Action, if we didn't set the Value of state in both client and server side, then how the incident gets resolved?
function resolveIncident(){
gsftSubmit(null, g_form.getFormElement(), 'resolve_incident'); //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(){
current.update();
}
can you help me to understand this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2019 12:47 AM
Hi Lakshmi,
may be many times you heard about Question like
can we have (can we call ) UI action at client side and server side? yes.
And this is the "Resolve" incident is a good example for this.
e.g Above example works at both the side,
like
when you click on button first then your script should check is it everything is valid information then only it should submit into database.
and in that case client side should get execute first,like any mandatory fields
like when you click on resolve you ll get
and when you fill this then it should execute server side function to update data.
Again bellow link will give Better idea about it,go through each line ,
https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
varsha