How do you add a dynamic filter option to a simple list/ data table instance widget?

thoma5
Giga Contributor

Hello,

So for this problem I need to add a dynamic filter option for a widget, so end users can customize what gets displayed on their list. Much like in ServiceNow, I want to be able to add a breadcrumb as well as custom filter to the table. I found this thread from a while ago  https://community.servicenow.com/thread/226535 and if you scroll down starting from Jesus, I see that this has not been answered in the last two years. Hopefully somebody has by now?

 

Thanks

1 ACCEPTED SOLUTION

That's what happens when you add these two parameters to your widget.



show_breadcrumbs: true,


enable_filter: true,



find_real_file.png



This is the condition to show the filter breadcrumbs


find_real_file.png



Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

11 REPLIES 11

Liju John1
Mega Guru

Add the following in the client controller



c.options.fields = 'u_name,u_number,u_company_id,u_group,u_state';


      c.options.show_breadcrumbs = true;


      c.options.show_keywords = true;



c.options.filter= 'u_state=Active';


Aditya Telideva
ServiceNow Employee
ServiceNow Employee

hI Thomas,


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 but just plain ol Form might work for it as well.


Let me know if this helps,


Aditya Telidevara


SanjivMeher
Kilo Patron
Kilo Patron

You will need to create a clone of the existing data instance filter and pass following two parameters to data-table widget



show_breadcrumbs: true,


enable_filter: true,



find_real_file.png



Please mark this response as correct or helpful if it assisted you with your question.

adityatelidevara sanjivmeher Hi guys, thank you for the input but I believe I am looking for something slightly different. The keywords search could be useful so I appreciate it. But what I meant by dynamic was allowing the user to make filter changes on the portal, without having to paste a filter in. I was looking more towards adding this filter editor to the top of a widget.   filter ex.png


Is that possible without a wild workaround?