g_list.getChecked() serverside equivalent

hamidouche
Kilo Expert

Hi,

I have a button on a list and I would like to display a message on the list saying how many records have been selected once I click the button:

gs.addInfoMessage(' You selected '  + numberOfSelectedRecords + '  records');

where numberOfSelectedRecords would be constructed as follows:

 

var checked = g_list.getChecked(); 

var arr= [];

arr = checked.split(',')

var numberOfSelectedRecords = arr.length;

 

the problem is that g_list.getChecked() is client side only. Is there an equivalent serverSide?

 

Thanks,

OH

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Unfortunately there is no serverside equivalent of this. But what i use alternatively is a ui action which has server and client side code both, check the link below

https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/

 

Using the above i use client side code g_list.getChecked(); to select the rows selected and pass them to server side to process further.

-Anurag

-Anurag

View solution in original post

6 REPLIES 6

Hi Hamid,

you need to handle this using GlideAjax possibly

sharing link for reference

https://community.servicenow.com/community?id=community_question&sys_id=67394325db5cdbc01dcaf3231f96...

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Regards
Ankur

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Actually i just tried and current.update works on selected rows. The Below ui action will work server side and only on the selected rows, no need to find the rows selected separately. I tried it.

 

find_real_file.png

-Anurag