sysparm_fixed_query is not working in UI Action

jordimsant
Tera Guru

I have created the following UI Action:

var fUtil = new FacturacioUtils();
var tasquesFacturades = fUtil.tasquesFacturades(current.projecte.toString());
var query = 'top_task=' + current.projecte + '^sys_idNOT%20IN' + tasquesFacturades.join(',');

var url = gs.getProperty('glide.servlet.uri') + `sys_m2m_template.do
?sysparm_fixed_query=` + query + `
&sysparm_m2m_ref=x_tntsl_tmn_factur_facturacio_m2m
&sysparm_collectionID=` + current.sys_id + `
&sysparm_collection=x_tntsl_tmn_factur_factures
&sysparm_collection_key=x_tntsl_tmn_factur_factures
&sysparm_collection_related_file=planned_task
&sysparm_collection_related_field=planned_task
&sysparm_stack=no `;

action.setRedirectURL(url);

Nonetheless, when I launch this UI Action the filter does not apply. I am sure query is generating right because if I change "sysparm_fixed_query" by "sysparm_query" it works fine, and I cannot create a before query BR because the tables I am using are in scope application. Does anybody know why "sysparm_fixed_query" is not working? Do you know how to fix it?

 

Thanks in advance!

5 REPLIES 5

Ahmmed Ali
Mega Sage

Hello @jordimsant 

 

As a workaround you an try using client script in UI action to redirect user to specific URL. The script include you can call from client script using GlideAjax (of course client callable script include).

 

Thank you,

ALi

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

I think I am not understanding. The matter is that if I change "sysparm_fixed_query" by "sysparm_query" it automatically works, and the other way around. If I just redirect to the same URL, I suppose it won't work neither.

I tried static link with fixed query in server script of UI action redirect and it did not work, but same link worked when I used client side script for UI action and location.href = URL;

 

Thanks,

Ali

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Chaitanya ILCR
Kilo Patron

Hi @jordimsant ,

 

you can create a Query BR instead

you can refer this

Solved: Using sysparm_fixed_query in URL - ServiceNow Community

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya