How to Capture selected ListView records and UI Action - UI Page Input for script processing ?

oyu
Tera Contributor

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.   

 

Is there a way to get a collection of the selected records from the listview (#1) and use it in the ...

 

Thank you.

 

 

 

 

4 REPLIES 4

jaheerhattiwale
Mega Sage
Mega Sage

@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

jaheerhattiwale_0-1671254316955.png

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

reshmapatil
Tera Guru

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:

 

https://<instance_name>.service-now.com/sys_ui_context_menu.do?sys_id=f55c67f00a0a0b3e0000729159a6ed...

 

 

Regards,

Reshma

**Please mark my answer correct or helpful based on the impact**

oyu
Tera Contributor

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.

 

Hi Oyu,

 

Did you find any solution . I am facing the same issue and need the solution urgently.

 

Thanks in advance!!