Fetching filtered query from List view

Prerna9
Mega Contributor

Hi All,

I am working on a requirement where I need to design a UI action for exporting CSV file of List filtered on RITM table. As the formatting of CSV file that Servicenow gives by default is different from our requirement, so we are writing Fix script to manage rows and columns of exported file.

But as filter condition of list view will be dynamic , so wanted to know if there is any way we can dynamically fetch Encoded query of current list view and place it in our query of script.

var gr = new GlideRecord(table);
gr.addEncodedQuery("metric.metric_type.evaluation_method=survey");
gr.query();

Highlighted query should be dynamic one as per the filter of current list page.

Thanks in advance!!

4 REPLIES 4

Voona Rohila
Kilo Patron
Kilo Patron

Hi prema

Try this and check below links

var uri = gs.action.getGlideURI(); // gives object from type GlideURI()
var quer = uri.get('sysparm_fixed_query'); // extracts fixed encoded query string
var quer2 = uri.get('sysparm_query'); // extracts users query string
gs.addInfoMessage(quer);
gs.addInfoMessage(quer2);

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

https://community.servicenow.com/community?id=community_question&sys_id=573bb92ddb7cc090414eeeb5ca96...


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

what do you mean by filter of current list page?

multiple users can apply multiple filters on table list

Regards
Ankur

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

Hi @Ankur Bawiskar ,

Suppose Customer A put filter "State= Open and Active= True"

Customer B put filter "State=Closed and Active= True and Catalog item = XYZ"

When Customer A is clicking on our Custom UI Action then I should get encodedquery for State=Open and Active= True. But if Customer B clicks on our UI Action then t should give me encoded query like State=Closed and Active=True and Catalog Item = XYZ.

Hi,

okay can you share what type of UI action it is?

Client side or server side

please share script and UI action configuration

Regards
Ankur

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