Auto add filter when query by business rule

Dat Phan
Tera Guru

I have a problem, I have a "u_demo_data" table and it has "u_import" column. I tried to use the business rule that auto-add condition "u_import=false" when the url has "sysparm_ignore_import=false". I tried the coding below in the business rule:

var isImported = gs.action.getGlideURI().getMap().get('sysparm_ignore_import");
if(isImported == 'true') {
current.addQuery('u_import', false);
}

It runs when I first open the screen. But it's not correctly, when I used the filter in the screen. I don't want to the fix_query.

What's the problem? I don't have a solution for this problem. Could you help me, please?

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Dat Phan 

so are you saying different filter should be applied when user navigates to the table from different place?

From which all places user will be navigating? why not form URL and give sysparm_query and user will be taken to the table with correct filter getting applied

Alternatively did you try to use the same script in table level READ ACL

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@Ankur Bawiskar For security reasons, I don't want the user to know the query filter. So I want to hide the query filter. And I just want it to run on some screens.

@Dat Phan 

then try to use advanced script in your table level READ ACL

 

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