- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2021 01:36 AM
Hi,
I have a requirement to get the user preference using dialog box in ServiceNow Change request. In dialog box, it will display the list of users in a list collector as below.
I used following steps,
1.Create a new UI page and it will use the macro to show the list collector as follows,
HTML
<div class="col-md-8">
<g:evaluate var="jvar_assignee" expression="RP.getWindowProperties().get('assignee_list')"/>
<g:macro_invoke macro= "lightweight_glide_list" id="change_subsystem" name="change_subsystem" control_name="QUERY:companyLIKEASP" reference="sys_user" can_write="true" list_data ="${jvar_assignee}" />
</div>
2 Create ui action and it will open the dialog box and pass the assignee_list,
var assignList = g_form.getValue("additional_assignee_list");
var dialog = new GlideDialogWindow("user_input");
dialog.setPreference("assignee_list", assignList);
dialog.render();
dialog.setTitle('Calendar Invite');
When the user click the OK button, I want to read the selected user list from list collector, but value is always null.
I tried following script to read the data from list collector, but those are not working.
1. var selectedList = gel('change_subsystem').value;
2. var selectedList = g_list.get(change_subsystem);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2021 04:51 AM
Hi,
I was able to get the sys_ids of the users from that list collector on UI page
Script:
HTML:
<?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:macro_invoke id="user" name="user" macro= "lightweight_glide_list" control_name="user" reference="sys_user" can_write="true"/>
<g:dialog_buttons_ok_cancel cancel="return onCancel();" ok="return onSubmit();"/>
</j:jelly>
Client Script: Notice the HTML ID -> for me it was select_0user
function onSubmit(){
var x = document.getElementById("select_0user");
var txt = "Selected users: ";
var i;
for (i = 0; i < x.length; i++) {
txt = txt + "\n" + x.options[i].value;
}
alert(txt);
}
Output:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2021 02:01 AM
Hi,
Have you tries with below syntax,
var selectedList = gel('jvar_assignee').value; or g_form.getValue('change_subsystem');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2021 04:27 AM
Hi Balaji,
Thanks for the reply, I tried your solution but it's not working..
BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2021 04:33 AM
Hi,
did you check the html id for that HTML element
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2021 04:51 AM
Hi,
I was able to get the sys_ids of the users from that list collector on UI page
Script:
HTML:
<?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:macro_invoke id="user" name="user" macro= "lightweight_glide_list" control_name="user" reference="sys_user" can_write="true"/>
<g:dialog_buttons_ok_cancel cancel="return onCancel();" ok="return onSubmit();"/>
</j:jelly>
Client Script: Notice the HTML ID -> for me it was select_0user
function onSubmit(){
var x = document.getElementById("select_0user");
var txt = "Selected users: ";
var i;
for (i = 0; i < x.length; i++) {
txt = txt + "\n" + x.options[i].value;
}
alert(txt);
}
Output:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader