
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 09-22-2020 06:54 AM
Hi,
In this article, I will show you how you can create a custom UI page in ServiceNow and call that in a popup.
For this, first we need to create a UI Page.
System UI -> UI Pages -> New
UI Page Name: ui_page_demo
HTML Script
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form>
<table>
<tr>
<td style="width:25%">
<g:form_label>
Name:
</g:form_label>
</td>
<td style="width:60%">
<input type="text" aria-label="Print your name" name="my_name" id="my_name" maxlength="25"/>
</td>
</tr>
<tr>
<td style="width:25%">
<g:form_label>
Select User:
</g:form_label>
</td>
<td style="width:60%">
<g:ui_reference name="user_ref" id="user_ref" query="user_nameSTARTSWITHa" table="sys_user" />
</td>
</tr>
<tr>
<td style="width:25%">
<g:form_label>
Select Incident:
</g:form_label>
</td>
<td style="width:60%">
<g:ui_choicelist name="my_category" id="my_category" table="incident" mandatory="true" field="category" query="active=true"/>
</td>
</tr>
<tr>
<td>
<g:dialog_buttons_ok_cancel ok_id="submitData" ok="return continueOK()" ok_type="button" ok_text="${gs.getMessage('Okay')}" ok_style_class="btn btn-primary" cancel_type="button" cancel_id="cancelData" cancel_style_class="btn btn-default" cancel="return continueCancel()"/>
</td>
</tr>
</table>
</g:ui_form>
</j:jelly>
Client Script
function continueOK() {
alert("OK clicked");
var gdw = GlideDialogWindow.get();
var name =gel('my_name').value;
var user = gel('user_ref').value;
var cat = gel('my_category').value;
var sys_id = gdw.getPreference('sys_id'); //get the values passed in the client script
var selected_value = gdw.getPreference('value'); //get the values passed in the client script
alert(name+"---"+user+"---"+cat+"---"+sys_id+"---"+selected_value);
GlideDialogWindow.get().destroy();
}
function continueCancel() {
alert("Cancel clicked");
GlideDialogWindow.get().destroy();
}
Processing Script
This will be useful if you are calling a UI page directly (instead of popup) and have a html form. Then all the submitted values of the form can be captured in the processing script like below. Do note that the processing scripts contains server side code and you can store the values in the table or do any other server actions from there.
var user = request.getParameter("user_ref"); //mention the name of the elment here
var my_name = request.getParameter("my_name"); //mention the name of the elment here
var category = request.getParameter("my_category"); //mention the name of the elment here
gs.info("Asif: testing "+user+"---"+my_name+"---"+category);
//you can do gliderecord and store or add any other server side code here
Once this is done, save this.
Now you can call this UI action in a popup from any client script. In our example, i am written this onChange client script of 1 field in incident form.
onChange Client Script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var dialog = new GlideDialogWindow('ui_page_demo'); //Mention your UI Page name here
dialog.setTitle('UI Page Demo'); //Set the dialog title
dialog.setSize(650, 600); //Set the dialog size
dialog.setPreference('sys_id', g_form.getUniqueValue()); //pass current object id
dialog.setPreference('value',newValue);//pass the selected value on the form
dialog.render(); //Open the dialog
}
Output
Let me know if you have any questions in the comments below.
Mark the article as helpful and bookmark if you found it useful.
Regards,
Asif
2020 ServiceNow Community MVP
- 30,502 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Asif,
Thanks for the article its quite useful.
Regards,
Viraj
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Asif,
Can you provide an example where the pop-up selects from field type = Table Name instead of reference to User table?
Thanks,
- Jerome

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Did not understand what you meant by that. Can you explain a little more with an example.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Asif,
Your example showed selecting a user from a reference field. I would like to know if the same thing is possible for a field type = Table Name.
E.g., see field "Creates" on this form:
https://devxxxxx.service-now.com/nav_to.do?uri=cmdb_ip_service.do?sys_id=db9840e10ab3015500f5e3fe8f78da42

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi,
There are only 3 components (jelly tags) supported by ServiceNow which are input field, checkbox and reference along with ok_cancel buttons.
For the kind of example you shown you might have to first fetch the options in a array and then use basic html dropdown and update the values in that.
Mark the article and comment as helpful if it helps.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thank you Asif for providing this.
Just one question here.
How can we show choice list value as it is. If I want to show form field values (record is already created) then how can we show the choice list value.
For eg. there are two fields, reference & choice list. In a reference field there is a value "Abc" and choice list has option "Mumbai" selected, then if I click on UI action then UI page should be displayed with two those two fields and also the values in it (like Abc and Mumbai).
Please guide me on this

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
In the UI page, do you wnat those to be changed. or just show them in plain text fields?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Yes, user should be able to change it as well.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hello Asifnoor, I have a question, I created a UI action to create a new task, this UI action is in the RITM form:
the idea is that when the user clicks on the UI action, the pop up window shows up, I made some modifications to the UI page which is this one:
how can I get the information from the pop up window copied to the new task created from the ui action? so when the user clicks on Submit, the new task is created with their information added, and if the user clicks on Cancel, nothing happens, and the user remains in the same page.
Thank you
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Could you please provide the code for that ui action

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi,
In the client script, you get the values and you can use GlideAjax and can do further processing.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi @asifnoor
it helped me for creating popup box/dialog box,but if the dialog box contains choice list fileds,how the data will be stored to the tables when we select any choice in drop down list,for me the data is not storing in the table,can you suggest me for that?

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Vijaya,
you will still get the values in the client script when you use this line (assuming category is yoru choice list)
var cat = gel('my_category').value;
And then you can parse and store as per the data type that you have.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
How to create any incident record using this pop up features?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I am working on UI pages where I need store values from popup box and based on the values stored from popup box I need to call a flow designer. But when I am trying to store those values through client script the are values are not holding in that field we I click ok the page gets reloaded and the values stored are cleared out. Someone help me with this.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I have referred this community page.
My requirement is When I click on UI action button, it should pop-up a custom dialog box and it should show some fields getting from incident_task. After this by clicking a confirm UI action button, it should create a new record/task.
As given in this article, I have created an UI Page with onchange client script.
But kindly someone suggest, how this can be done with OnSubmit client script.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This is very helpful and clearly explained, thank you. I want to call the UI page from an onLoad script of a new record and pass the values collected back the unsaved record?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi @asifnoor
This is one such useful article. I just came across your article. Can you please help me with my query which is quite similar to this?
I have a requirement in which I need to see a preview or open the record of the selected roles field by clicking the field value.
This is the requested item form (service catalog). So this selected roles field is a multi line text field. Similar to how we have a preview icon for reference field I need to create one to show the preview of the selected fields. If I click one particular role can I open a UI page as a pop up that shows the preview of the particular field. Is this possible? Please help!!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
anyone know how to update the contents of the UI page depending on what the user selects from the UI page.
Like if the user selects a user and know we need to display the data for that user under the field.