Configuration item on standard change template

Brian Lancaster
Tera Sage

When creating or modifying a standard change the configuration item field does not filter out retired CIs like it does when choosing a CI on a change record. Is there any way to get this to work or some sort of workaround?

2 ACCEPTED SOLUTIONS

Niklas Peterson
Mega Sage
Mega Sage

Hi @Brian Lancaster ,

Here is an old KB on why and a suggested resolution.


https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0723752

Create a Before Query type business rule on cmdb table to filter out the retired records.

 

Here is an community post that has a script example:
https://www.servicenow.com/community/developer-forum/applying-reference-qualifiers-on-standard-chang...

 


Regards,
Niklas

View solution in original post

Brian Lancaster
Tera Sage

Figured it out. Since I did not want to limit the entire system to just things that had an install status of installed I used operational status as that appears to be the same for all CMDB tables. So I just change the before query to the code below.

(function executeRule(current, previous /*null when async*/ ) {
    current.addQuery('operational_status', '!=', 6); // Anything other then retired
})(current, previous);

View solution in original post

4 REPLIES 4

Niklas Peterson
Mega Sage
Mega Sage

Hi @Brian Lancaster ,

Here is an old KB on why and a suggested resolution.


https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0723752

Create a Before Query type business rule on cmdb table to filter out the retired records.

 

Here is an community post that has a script example:
https://www.servicenow.com/community/developer-forum/applying-reference-qualifiers-on-standard-chang...

 


Regards,
Niklas

This doesn't seem to work if someone just start typing in the configuration item field. It does work if they click on the magnifying glass however. But I know everybody is just going to start typing in the name of the CI.

 

Edit: It seems to be this part of the code. If you just type it return null as the answer but if you click the magnifying glass it returns change_request.cmdb_ci.69023fa0690297006902da4069023d80.

var targetName = gs.action.getGlideURI().getMap().get('sysparm_target');

 

I found the main problem. I was trying to not be so restrictive since this can affect the entire system. So I tried to change it to 

current.addQuery('install_status', '!=', 7);

which is retired. The problem comes in that 7 is not retired for all classes. Are retired CIs are in Business Application which yes I know technically your not supposed to use that as an operational CI but that is what are vendor had use do until we could start coming up with Application Services. For some reason the class of Business Applications retired is 3 which for all other CIs is In Maintenance.  

Brian Lancaster
Tera Sage

Figured it out. Since I did not want to limit the entire system to just things that had an install status of installed I used operational status as that appears to be the same for all CMDB tables. So I just change the before query to the code below.

(function executeRule(current, previous /*null when async*/ ) {
    current.addQuery('operational_status', '!=', 6); // Anything other then retired
})(current, previous);