GlideList API - How to get records sys ids?

Hellczi
Kilo Explorer

Hi folks,

I am playing with custom UI context menu action that allows ITIL users to bulk update the records.
The plan is to merge OOB "Update Selected" and "Update all" UI context menu actions.

So, I want to pass a comma-seperated list of ids to script include via ajax and I've found it quite challenging as I am not that familiar with the Glidelist API.

I know that for selected records I can utilize the g_list.getChecked() which is briliant and works exactly as I expected - it returns a list of sys_ids of currently checked records.

Question: Is there any method that does exactly the same as getChecked() but for all records in the list?

I need a comma-seperated lists of records to put them in a gliderecord query  - like gr.addEncodedQuery('sys_idIN' + listsOfrecords)

Cheers,
Maciek

3 REPLIES 3

sachin_namjoshi
Kilo Patron
Kilo Patron

You can print glide list sys_id using below sample script, watch list is a glide list field.

 

var inc = new GlideRecord('incident');
inc.addEncodedQuery('watch_listLIKE' + getUserSID('Abel Tuter'));
inc.query();

while (inc._next()) {
  gs.print(inc.number + " | " + inc.watch_list);
}

 

 

thanks, but how this help me with the UI context menu action? 

Hellczi
Kilo Explorer

nvm, g_list.getQuery() is all I need <facepalm>