How best to generate link to record list with query parameters

sherman_1206
Tera Contributor

I would like to create a UI action on Incident Form which pops up another window (a list of incidents) filtering for certain incidents.

My UI action is the following:


function showWithSameStation() {
     var query = 'u_station='+g_form.getValue('u_station')+'^number!='+g_form.getValue('number')+'^opened_at>=javascript:gs.daysAgo(30)';
     var url = "./nav_to.do?uri=incident_list.do?sysparm_order=number%26sysparm_order_direction=desc%26sysparm_query="+ query;
     alert( url );
     window.open( url );
   
}


When clicking this the alert shows following link:
./nav_to.do?uri=incident_list.do?sysparm_order=number%26sysparm_order_direction=desc%26sysparm_query=u_station=721e04b40a0a3c6a00e84812eef389e0^number!=INC2526591^opened_at>=javascript:gs.daysAgo(30)


Which looks alright, I even tried calling "escape" on the url variable which did not help.

Basically I want to filter for incidents which have the same value for u_station, not the same incident number as current record, and opened in the last 30 days. My problem is related to the opened_at portion of the query.

Originally, I just generated a query from list copied the query by right clicking breadcrumb and changed out the "u_station" and "Number" values with g_form.getValue calls and modified opened_at portion to make a javascript:gs.daysAgo() call but this is not working.

Anyone able to clear up my confusion here? Thanks!
2 REPLIES 2

tony_fugere
Mega Guru

I know this is the perfect testing method or debugging here, but I tried running this portion of the URL and noticed that my browsers will convert the percent to %25 resulting in a bad URL.


incident_list.do?sysparm_order=number%26sysparm_order_direction=desc%26sysparm_query=u_station=721e04b40a0a3c6a00e84812eef389e0^number!=INC2526591^opened_at>=javascript:gs.daysAgo(30)


Maybe decode it and let the browser do its thing?

incident_list.do?sysparm_order=number&sysparm_order_direction=desc&sysparm_query=u_station=721e04b40a0a3c6a00e84812eef389e0^number!=INC2526591^opened_at>=javascript:gs.daysAgo(30)


Yep, this was my mistake.

It is actually much easier to copy the URL from list breadcrumb for link generation. Using the query string means you need to deal with the escaping.