How to get the Related list query using UI Action

jigs1
Kilo Contributor

Good day everyone šŸ™‚

I would like to ask for some help, we have this requirements to Invite All users found on the filtered related list (see sample screenshot below: to invite 76 users at once by clicking Invite All UI action). the total number of records is changing based on the filter(s) selected by the user (sample Invited=false > Excluded = false > Computer Location City > Gurugram).
Related list filter(s) is dynamic per admin user's input (but this filter is fixed Invited=false > Excluded = false since we will only invite those users who were not invited yet) 
Once the admin provided some filters, then click Invite All ---- i want to get the related list filter(s), and do the GlideRecord after to update Invited column to true. How to get the related list query using Invite All UI action?

sample:
find_real_file.png

If need more samples/explanation please let me know so i can provide. I would love to discuss and learn from you.

Thank you so much

Jigs

1 ACCEPTED SOLUTION

Manish Vinayak1
Tera Guru

Hello,

You can access the related lists on the bottom of the page using GlideList2 API. Here is the documentation for GlideList2:

https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=c_GlideList2API

 

You will see that using the "get(id)" function in GlideList2, you can get the instance of the related list tab. And then by using the "getQuery()" function or ".filter" attribute, you can access the applied filter.

So you will need to use client side code in your UI Action. In the client side action, use the following code:

 

//You need to specify the Id of the related list to get its instance

var relatedList = GlideList2.get("id of the related list");
if(relatedList) {

var filter = relatedList.getQuery();
// OR you could use the following
//var filter = relatedList.filter;
}

 

Following explains how you can find the ID of the related list tab:

find_real_file.png

Using the browser developer tools, inspect the hamburger button for the tab you want to get the query from. Try to find the attribute 'data-list-id' for that related list tab. That is the "listId" to be passed in the following call:

GlideList2.get(listId);

Hope this helps!

Cheers,

Manish

View solution in original post

5 REPLIES 5

Manish Vinayak1
Tera Guru

Hello,

You can access the related lists on the bottom of the page using GlideList2 API. Here is the documentation for GlideList2:

https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=c_GlideList2API

 

You will see that using the "get(id)" function in GlideList2, you can get the instance of the related list tab. And then by using the "getQuery()" function or ".filter" attribute, you can access the applied filter.

So you will need to use client side code in your UI Action. In the client side action, use the following code:

 

//You need to specify the Id of the related list to get its instance

var relatedList = GlideList2.get("id of the related list");
if(relatedList) {

var filter = relatedList.getQuery();
// OR you could use the following
//var filter = relatedList.filter;
}

 

Following explains how you can find the ID of the related list tab:

find_real_file.png

Using the browser developer tools, inspect the hamburger button for the tab you want to get the query from. Try to find the attribute 'data-list-id' for that related list tab. That is the "listId" to be passed in the following call:

GlideList2.get(listId);

Hope this helps!

Cheers,

Manish

Namaste Manish,

Thank you so much for responding. Explanation is bahut clear and straight forward. Now, i have the clearer understanding of what would be my next move. 

Let me go through this and come back once.

 

Thanks a lot!

Jigs

 

 

Namaste Jigs šŸ™‚

No worries. Give it a try. Please mark the response as helpful / correct based on its impact.

Thanks,

Manish

Namaste Manish,

Good day. Aap kaise hain? 

 

Thank you for waiting. I was working on other tasks before this, and i was out of office for a week so just came back šŸ˜„

Anyhow, just want to inform you that I was able to get it correctly and this feature is working as expected. 

Thank you so much šŸ™‚

 

with thanks,

Jigs