How to Capture selected ListView records and UI Action - UI Page Input for script processing ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2022 01:44 PM
I would like to have the ability to perform bulk updates to a set of selected listview records with user provided values.
The desired UI process:
1. Allow a user to select records from a listview.
2. Provide a 'List Context menu - UI Action' to open a UI Page to prompt user for Input value(s).
3. Invoke a Script (e.g. Glide Ajax) to update the selected records and perform other processing with the Input values provided from the UI Page.
I tried g_list from the UI Page to collect the selected records into UI Page but does not seem to work.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2022 09:19 PM
@oyu Write the following script in UI action
function bulkUpdate() {
if (g_list.getChecked().toString().length > 0) {
//Call glide ajax here
}
}
Please check below image as well
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2022 06:16 AM
Hi @oyu ,
Why do you want to have UI Page when we have OOB 'Update Selected' and 'Update All' context menus?
If you still want to create custom UI Action use below code:
var keys = g_list.getChecked();
if (keys == '') {
var msg = new GwtMessage().getMessage('There are no rows selected');
alert(msg);
return;
}
var url = new GlideURL(g_list.tableName + '_update.do');
url.addParam('sys_action', 'sysverb_multiple_update');
url.addParam('sysparm_multiple', 'true');
url.addParam('sysparm_nostack', 'yes');
url.addParam('sysparm_checked_items', 'sys_idIN' + keys);
url.addParam('sysparm_view', g_list.getView());
window.location = url.getURL();
Refer to OOB 'Update Selected' context menu:
Regards,
Reshma
**Please mark my answer correct or helpful based on the impact**
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 08:26 AM
Thank you for your response!
I am trying to use a UI Page to prompt the user for some value(s).
Then use the value(s) along with the g_list items to drive a set of updates by using Glide_ajax.
In the Ui Page, I'd like to present the User with sys_user list selection list. Once that is submitted, I'd like to pass the g_list and selected user for further Glide Ajax processing.
Is this possible to collect g_list and additional value from the Ui Page to pass to Glide Ajax?
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 12:43 PM
Hi Oyu,
Did you find any solution . I am facing the same issue and need the solution urgently.
Thanks in advance!!