Encoded Query for Filter

Sam Ogden
Tera Guru

HI All,

We have the below encoded filter on a simple list widget on our Customer Portal:

companyINjavascript:new CDL_getParentChild().getCompanyCDL(gs.getUserID())^active=true^EQ^ORDERBYDESCopened_at

I need to amend this so that this simple list will only disply if the user has the following role: customer_portal_show_all_comp

If the user does not have this role then it should display no results and as we have the show then empty box not checked then the widget should not display.

I'm not sure how to amend this query to achieve this, I tried the following, but this stopped any results showing for all users, including those that had the role:

companyINjavascript:new CDL_getParentChild().getCompanyCDL(gs.getUserID()&&gs.hasrole(customer_portal_show_all_comp))^active=true^EQ^ORDERBYDESCopened_at

I also tried the following, but this still showed the results even for people without the role:

companyINjavascript:new CDL_getParentChild().getCompanyCDL(gs.getUserID())^active=true^gs.hasrole(customer_portal_show_all_comp)^EQ^ORDERBYDESCopened_at

Any help is greatly appreciated.

Thanks

1 ACCEPTED SOLUTION

jesseadams
ServiceNow Employee
ServiceNow Employee

I can't think of a way to do it through the encoded query.. that's just going to add a filter to the records in your list but you can only filter based on the columns on that table so I don't think checking for the users role will work.



One way would be to clone simple list and add a role to your clone.


Then use that cloned widget to display the list that you want only shown for that role.


View solution in original post

2 REPLIES 2

jesseadams
ServiceNow Employee
ServiceNow Employee

I can't think of a way to do it through the encoded query.. that's just going to add a filter to the records in your list but you can only filter based on the columns on that table so I don't think checking for the users role will work.



One way would be to clone simple list and add a role to your clone.


Then use that cloned widget to display the list that you want only shown for that role.


Hi Jesse,



Makes complete sense why my query wouldn't work.   I didn't think about the widget itself.   I've added the role and works a treat, thanks for your help.