How Adding Icons to UI Action Buttons in ServiceNow
UI actions seem to be essentially UI components which can be displayed throughout the form, that when these UI elements were also activated, a script (Javascript code) is implemented; the whole script is written throughout the UI action script segment.Throughout ServiceNow, UI Actions are being used to consider making the UI extra immersive and configurable. Form buttons, form context menus, form links, list banner buttons, list context menus, list choices, and list links are examples of UI elements that can be displayed in a type. The Servicenow Training will help you to get more knowledge in the subject.
In servicenow, UI actions could be operated on both the client and server sides. However, the majority of the time, UI actions must be run on the server side. Tables as well as database opinions in the same context can have UI actions added to them.
ServiceNow ui actions can be defined by users with the admin as well as ui action admin roles.
The UI actions include the following elements such as:form buttons, form links, form context menu items, list buttons, listlinks, UI actions, list choices and list context menu items, etc.
Now we will go through on how to create UI action buttons in the servicenow.
Important steps to create UI action buttons:
-
Simply browse through the system definition section in that select the UI actions as shown in the below image.
-
Based on your requirement, you need to select the new or open the existing record.
-
Just click on the new option to create a new UI action. In this section you need to configure the form details .
-
As the next step you can set the UI action for client and server side as well. Along with some specified conditions.
-
Next click the submit button and update it if you opened an existing record or else leave it.
Depending on our preference, we can create UI actions besides client-side scripting or server-side programming. To make a UI action operate on a client-side script, initially select the client field checkboxes.
Whenever the UI action is picked, the onClick field executes the business logic enclosed within it. As a result, we request a function throughout this field and identify it in the primary script field.
People only have to call the following format for code inside the onClick field:
ReOpenedIncident();
After which, inside the script field, people can measure the position and include the code that we’d like to execute:
function onClick()
{
/ Create a script that will run when a UI Action is selected.
}
This technique of declaring a function as in the script field is being used by the ServiceNow UI actions which come with the portal out of the package.
Now that we’ve seen when to use client-side scripts in UI actions, designers can take it a step further using both client- and server-side scripts in almost the same UI action.
This could be accomplished by first executing client-side script throughout the UI action, which then executes the UI action and in code, which executes the server-side script.
First, let’s take a gander just at piece of code in the client-side code which really calls its UI action:
gsftSubmit(null, g_form.getFormElement(), ‘<ui_action_name>’);
The subsequent code invokes the UI action, however this moment this will be executed mostly on server.
The identity mentioned within the script is being used in the Action name field of a UI action.The very first argument with gsftSubmit will be for a regulation, but since we don’t need it, we simply pass null.The purpose of the second argument is to obtain the form. Throughout this case, all we need is an existing HTML form.
Now let’s have a look at the server side of the scripting.
if(typeof window == ‘undefined’)
serverSideCode();
function serverSideCode() {
//Run the server side UI Action code
}
The very first component of such a code is such an if statement which checks to see if developers are on the server side but not the client side. One such small computer program also guarantees how no browser problems arise. If indeed the if statement returns true, we invite a function to execute our server-side code. Throughout our script field, people could use the preceding instance as well as request each onClick function.
function onClick() {
// Write script here to run when an UI Action is selected
gsftSubmit(null, g_form.getFormElement(), ‘incident_ui_action’);
}
if(typeof window == ‘undefined’)
serverSideCode();
function serverSideCode() {
//Run the server side code
}
Conclusion:
In the above blog post we had discussed the adding of UI action buttons in servicenow from the client side and server side scriptings. Had any doubts please drop comments in the communication section. We will get back to our queries with absolute answers. Become a Servicenow Certified professional by learning this Servicenow Training In Hyderabad !