How to get full query from a defined related list

Aaron Dalton
Tera Expert

I'm setting up a related list using a defined Relationship that adds specific queries to the list. These queries don't appear in the breadcrumbs of the related list and also don't show up using a UI Action and calling g_list.getQuery(). 

 

Is there a way to access the relationship's queries from a related list using a UI action?

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

You may have to go to the DOM on this one (as much as I don't like that), because the query isn't actually associated with the related list in the view that we can see and seems to be added another way.

I was able to get the query by doing something like this showing all pieces:

AllenAndreas_0-1676505011685.png

AllenAndreas_1-1676505034830.png

Find list back-end name by right-clicking any column header and choose Configure > List Control

AllenAndreas_2-1676505280725.png

Copy list name: 

AllenAndreas_3-1676505308474.png

Use script like this in your UI Action (needs to be client side) AND add _table to the end of your list name like so:

AllenAndreas_5-1676505475059.png

function findFilter() {
    var list = document.getElementById('incident.REL:86e358a1970de5509b483a300153af03_table').getAttribute('glide_list_query');
    alert("Filter is: " + list);
}

Then finally...when it's all said and done...you get:

AllenAndreas_6-1676505512136.png

 

AllenAndreas_7-1676505535185.png


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

5 REPLIES 5

Claude DAmico
Kilo Sage

This seems like it would be helpful to you.

https://www.servicenow.com/community/developer-blog/query-business-rules-a-definitive-guide/ba-p/227... 

Claude E. D'Amico, III - CSA

Allen Andreas
Administrator
Administrator

Hi,

You may have to go to the DOM on this one (as much as I don't like that), because the query isn't actually associated with the related list in the view that we can see and seems to be added another way.

I was able to get the query by doing something like this showing all pieces:

AllenAndreas_0-1676505011685.png

AllenAndreas_1-1676505034830.png

Find list back-end name by right-clicking any column header and choose Configure > List Control

AllenAndreas_2-1676505280725.png

Copy list name: 

AllenAndreas_3-1676505308474.png

Use script like this in your UI Action (needs to be client side) AND add _table to the end of your list name like so:

AllenAndreas_5-1676505475059.png

function findFilter() {
    var list = document.getElementById('incident.REL:86e358a1970de5509b483a300153af03_table').getAttribute('glide_list_query');
    alert("Filter is: " + list);
}

Then finally...when it's all said and done...you get:

AllenAndreas_6-1676505512136.png

 

AllenAndreas_7-1676505535185.png


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

This is exactly what I needed! For some reason I couldn't get it to work in my UI Action itself even though "Client" was checked and "Isolate Script" was FALSE. However, since I'm using a UI Page with this as well, I just moved this script into there. Works perfectly. Thanks so much!

Awesome, glad it was helpful and provided a good solution for you to use.

Take care! 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!