How to put a default filter when "adding" to a related list via the "add" button

fredfariello
ServiceNow Employee
ServiceNow Employee

Hello. Trying to put a default filter on a Related list "Add" function (impacted ci's where it only shows non-retired CI's. OOTB is "ALL". NOTE: List Control does not work when in "add" mode on a related list because you are going through the UI action and are simply presented with CMDB_CI (no filter). The Edit Default Filter field will not show up on LIST CONTROL form to create a default filter. Per the docs, the Edit Default Filter field in the List Control form only is visible in a resting related list.

So, another approach is to edit the ADD UI Action on this list to “filter” whenever someone clicks “add” from this related list, but do not know how to modify the script to do this as Javascript is not my strong suit and do not want to break the UI Action. See attached for screenshots

What I am trying to filter is add the condition:

Status Is Not Retired (status !=7) 

 
1 ACCEPTED SOLUTION

MrMuhammad
Giga Sage

Please follow below steps.

Open Script Include - AssociateCItoTask 

On Line 36 add - url.set("sysparm_query", 'install_status!=7');

find_real_file.png

 

OUTPUT

find_real_file.png

Save it and you are done!

Refresh your Change request page and test it out!

Please note - we are changing OOB script that will skipped future upgrades. So Make sure to assess the skipped upgraded related to this script include and accept/reject as you want.

Thanks,

Sharjeel

Regards,
Muhammad

View solution in original post

2 REPLIES 2

MrMuhammad
Giga Sage

Please follow below steps.

Open Script Include - AssociateCItoTask 

On Line 36 add - url.set("sysparm_query", 'install_status!=7');

find_real_file.png

 

OUTPUT

find_real_file.png

Save it and you are done!

Refresh your Change request page and test it out!

Please note - we are changing OOB script that will skipped future upgrades. So Make sure to assess the skipped upgraded related to this script include and accept/reject as you want.

Thanks,

Sharjeel

Regards,
Muhammad

That is spot on correct! Thank you. Bummer that I need to change an OOTB script include though if documented as comments in the script include itself and upgrade notes it can work. Thanks again!