Simple List Widget Filter

Sam Ogden
Tera Guru

Hi All,

I've added a couple of simple list widgets to our portal, however I want to filter these by the company that the logged in user is part of.

I know if I wanted to filter the logs by the logged in user I could run a filter with opened by > is (dynamic) > ME, I'm just not cure how to do something similar for company as there is now is (dynamic option).

Any help is greatly appreciated.

1 ACCEPTED SOLUTION

Harihara Sudha1
Kilo Expert

Hi Sam,



You can use javascript:gs.getUser().getCompanyID() condition in your filter. Below screen shot for your reference.



find_real_file.png


View solution in original post

8 REPLIES 8

Harihara Sudha1
Kilo Expert

Hi Sam,



You can use javascript:gs.getUser().getCompanyID() condition in your filter. Below screen shot for your reference.



find_real_file.png


Hi Hari,



Thanks for the above, how would this need to be for an encoded query string so I can use it on the widget?


To specify a Dynamic Filter, the easiest way is to capture the encoded query string for your filter using this wiki article: Encoded Query Strings - ServiceNow Wiki.   Then paste that filter string into the edit panel of the widget in the Service Portal Designer.



You can also edit the widget by navigating to the Service Portal page the widget is on, CTRL+Clicking the widget, and then selecting Instance Options from the context menu.



Screen Shot 2016-06-13 at 11.10.09 AM.png



The page can technically be any page with widgets that accept the following parameters: sys_id, table, view.



The out of box page for this is Ticket Form.




Thanks,


Vinitha.K


Hi Vinitha,



I've got a further requirement for my filter.   Some our customers belong to a parent company and I would need the filter to show any logs that are for the logged in users company or any of their child companies.   Our implementation partner created a script includes that is used in other parts of the system.   Is this something that can be used within the filter or do I need to do something else?   below is the script includes:


find_real_file.png


find_real_file.png