How to create interactive filter for year wise

Uday Gonuguntla
Giga Guru

We need an interactive filter where user can select years like 2010 or 2011 or 2019 etc.. instead of last year or this year. Please help me.

UdayGonuguntla_1-1671008782740.png

 

4 REPLIES 4

Kalyani Jangam1
Mega Sage
Mega Sage

Hi @Uday Gonuguntla 

 

You can create custom date/time filter option like below

  1. Navigate to All > System Definition > Business Rules.
  2. Open the business rule Get Date Filter Options for Date Filters.
    This rule populates the list of selectable options in forms for new or existing date type interactive filters.
  3. On the Advanced tab, modify the Script field to include the JavaScript needed to add the new option. Add the following line:
  4. answer.add('2020_One year ago@javascript:gs.monthsAgo(24)@javascript:gs.endOfThisMonth()', gs.getMessage('2020'));
  5. answer.add('2019_One year ago@javascript:gs.monthsAgo(36)@javascript:gs.endOfThisMonth()', gs.getMessage('2019'));

 

For more information please refer below docs

https://docs.servicenow.com/bundle/tokyo-now-intelligence/page/use/dashboards/reference/r_CustomPubl...

 

Please Mark Helpful and correct if it helps you.

 

 

I'm getting like this

UdayGonuguntla_0-1671014012399.png

 

You can add below line

nswer.add('2021_One year ago@javascript:gs.monthsAgo(12)@javascript:gs.endOfThisMonth()', gs.getMessage('Year 2021'));

jaheerhattiwale
Mega Sage
Mega Sage

@Uday Gonuguntla 

Go to your dashboard

Click on + icon as shown in image below

jaheerhattiwale_0-1671010765758.png

 

Select interactive filters from dropdown and click on Date as in image below

jaheerhattiwale_1-1671010827841.png

 

Click on #New Date and then click on Add button

 

jaheerhattiwale_2-1671010868092.png

Date filter will be added to dashbaord as below, click the link shown in image

jaheerhattiwale_3-1671010940156.png

 

Fill the form to create new interactive filter

Move the filter conditions required to right

jaheerhattiwale_4-1671011017913.png

 

Save the form and go to related list to add on which table and field this filter should apply

Create new in related list as in image below

jaheerhattiwale_5-1671011080274.png

 

I selected incident table and created date.

Submit the form and come back to dashboard to see added interactive filter

 

jaheerhattiwale_6-1671011168744.png

 

 

Please mark as correct answer if this solves your issue.

 

 

 

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023