Is that possible to display a drop-down variable in a pop-up window?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2017 06:24 AM
Hi All,
Is that possible to display a drop-down variable (with few values in it) in a pop-up window once a button is clicked?
Please share your ideas.
Thanks & Regards,
Ram Prakash
- Labels:
-
Enterprise Asset Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2017 03:02 PM
Hi Ram,
yes. It is possible.
First I suggest you to have a look on http://wiki.servicenow.com/index.php?title=Displaying_a_Custom_Dialog#gsc.tab=0
You can test the above link easily in your Servicenow instance.
For example you have an UI Action in a Form, and you want to open a pop-up window contain a drop-down list.
Here is an example UI Action code:
function popupDispList() {
//Initialize and open the dialog
var dialog = new GlideDialogWindow("add_comments_dialog"); //Instantiate the dialog containing the UI Page 'add_comments_dialog'
dialog.setTitle("My pop-up Window Title"); //Set the dialog title
dialog.render(); //Open the dialog
}
Until now pressing our UI Action button will open our pop-up window.
How to have a drop-down in my window?
For that, we need to define a UI Page named "add_comments_dialog".
You should fill two part in your UI Page. The HTML part and the Client Script part.
For HTML part you can give the below code:
<g:ui_form>
<select id="dropdownlist" name="dropdownlist">
<option value="" selected="selected">-- Select --</option>
<option value="Ali" >Ali</option>
<option value="Reza">Reza</option>
</select>
<!-- Set up form fields and labels -->
<table width="100%">
<tr id="dialog_buttons">
<td colspan="2" align="right">
<!-- Add OK/Cancel buttons. Clicking OK calls the validateComments script -->
<g:dialog_buttons_ok_cancel ok="return validateComments()" ok_type="button" cancel_type="button" />
</td>
</tr>
</table>
</g:ui_form>
For Client Script part you can give the below code. This script will write your selected item in a field in your Form:
function validateComments() {
//This script is called when the user clicks "OK" in the dialog window
if (dropdownlist != '') {
g_form.setValue("description", dropdownlist); //Set the "description" field in my Form which has a UI Action with selection in the drop-down list
}
}
I hope I could give you a brief way of doing what you need.
Best wishes
Alireza