MrMuhammad
Giga Sage

ADD Button is not like a traditional related list Button i.e. Edit, New. As the Add button opens up a Pop-up instead of a slush bucket so the default filters using List Controls don't work. The Good News is, this can be achieved by modifying the OOTB Script Include. [Make sure to Assess and accept/reject upgrades to this script include post upgrade]

Story

Put a Default Filter on Impacted CI's Related List on the Change Request form to show only those CI's which doesn't have STATUS = RETIRED when I click on ADD Button.

Solution

The backend functionality of the ADD button is controlled by a Script Include AssociateCItoTask. We are going to add an encoded query to apply as a filter.

1. Go to the cmdb_ci table and apply a filter on List based on your requirements. Right-click on the filter and select a copy query. This copied query will be used in the script include, in our next step. 

find_real_file.png

 

2. Open the AssociateCItoTask Script include. Inside function _getUrl(), On line # 35, add the below line of the script.

url.set("sysparm_query", 'install_status!=7');

Please note - Line number can be different but make sure you group the above line with the existing url.set(..) method.

find_real_file.png

 

3. Save the Script Include and then open any change request. Scroll down to Impacted Services/CI related list and click on the ADD button. You will see a default filter there.

find_real_file.png

Hurrah! We are done. 🙂

If this was helpful, please make sure to give it a thumbs up [HELFPFUL]. Also, bookmark this for future reference. 

Visit my PROFILE for other good articles, that you might love. 

 

 

Comments
Rachit Aggarwal
Giga Explorer

Thank you so much for this community post as I have spent lot of time to find the solution for this.

MrMuhammad
Giga Sage

Hi Rachit - Happy that you found it helpful!

 

David Pleasance
Kilo Contributor

This was awesome. I am not a Java Scripter, but I was able to easily implement this to filter by the column 'sys_class_name'. This was such a benefit as it allowed me to hide Classes that will only confuse our Users today (I will change this filter later, when we're ready to reveal more CI Classes). Thank you!

MrMuhammad
Giga Sage

I am glad that helps, Thanks!

Brad Shedd
Tera Contributor

Hello Muhammad

 This was a big help, but I did realize that this is applied to the Affected CIs tab as well, which it shouldnt. Any idea on how to have it apply to just Impacted Services/CIs?
 
 
 
 
RaySNmond
Tera Contributor

Hi, 

 

Is there any way to achieve the same approach in the service operation workspace?

 

Thanks & Best Regards,

Raymond

Nilesh Pol1
Giga Guru

Hi,

a new query added on line 35 i wanted to works only for change requests impacted ci related list and not for incidents related list how do we achieve this ?

quiksilver
Mega Guru

Hi,

 

Is the solution still valid? 

 

I noticed there is a code changed compared to the original post 5 years ago

Version history
Last update:
‎09-19-2020 04:32 PM
Updated by: