Ui Builder - list component : fetch sysId's from selected records

Jonas VK
Tera Guru

Hi all, 

I have a question about the list component. 
Is there a way that I could fetch the sysId's from records that got selected from the list? (see image)
Is this possible with a client script or a certain event?
find_real_file.png

Thanks in advance.

1 ACCEPTED SOLUTION

JagjeetSingh
Kilo Sage
Kilo Sage

Hi,

Here is how you can do it.

1. Your list component has an event named "Selected row count updated". This event is triggered whenever you select a record in row.

2. To see what is the data returned from an event, you can create a page script. Use below code to log the event payload to console.

console.log(JSON.stringify(event.payload));

I use this in every page I build to see what an event is returning.

3. In this payload you'll find the record sysId along with other useful data.

 

Mark my response correct if worked for you. 🙂

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023

View solution in original post

4 REPLIES 4

JagjeetSingh
Kilo Sage
Kilo Sage

Hi,

Here is how you can do it.

1. Your list component has an event named "Selected row count updated". This event is triggered whenever you select a record in row.

2. To see what is the data returned from an event, you can create a page script. Use below code to log the event payload to console.

console.log(JSON.stringify(event.payload));

I use this in every page I build to see what an event is returning.

3. In this payload you'll find the record sysId along with other useful data.

 

Mark my response correct if worked for you. 🙂

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023

Hi, this helped me figure it out, thank you

in the similar manner do we have any event to get not selected records sys_id ? 

If you'll notice, the event provides us with a lot of useful data.
- If you are selecting few records, then it'd give you records sysId's as well as encoded query. This query you can use to get further details.

 - If you are selecting all the records then you won't get record sysId's. You can use encoded query only.

- If you select most of the records and leave a few then yes, you'll get unselected records with encoded query.

 

 

 

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023