Field Reference Qualifier Question

Sean Burton
Tera Expert

Can someone please outline what this reference qualifier for a CI field means? Its on my change records.

 

javascript: ['incident', 'problem'].indexOf(current.sys_class_name + '') == -1? '' : 'operational_statusNOT IN' + new OpsStatusFilter('cmdb_ci').by('CreateTask').join()

1 ACCEPTED SOLUTION

swapnali ombale
Kilo Sage

Hi @Sean Burton 

 

 to summarize, this reference qualifier does the following:

* If the current Change record was NOT created from an Incident or a Problem: Show all active CIs without any specific filtering based on their operational status.

* If the current Change record WAS created from an Incident or a Problem: Show only those CIs whose operational_status is not in the list of statuses deemed unsuitable for CIs associated with Incidents or Problems (as determined by the custom OpsStatusFilter script include).

Why is this done?

This type of filtering is often implemented to ensure data integrity and proper lifecycle management. For example:

* You might not want to associate a CI that is already retired or in a failed state with a new change request originating from an incident.

* It helps guide users to select CIs that are relevant to the context of the originating Incident or Problem.

In conclusion, this reference qualifier dynamically adjusts the available CIs on your change records based on their origin, applying a specific operational status filter when the change is related to an Incident or Problem. To fully understand the exact operational statuses being excluded, you would need to examine the OpsStatusFilter script include in your ServiceNow instance.

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. 

 

 

View solution in original post

2 REPLIES 2

swapnali ombale
Kilo Sage

Hi @Sean Burton 

 

 to summarize, this reference qualifier does the following:

* If the current Change record was NOT created from an Incident or a Problem: Show all active CIs without any specific filtering based on their operational status.

* If the current Change record WAS created from an Incident or a Problem: Show only those CIs whose operational_status is not in the list of statuses deemed unsuitable for CIs associated with Incidents or Problems (as determined by the custom OpsStatusFilter script include).

Why is this done?

This type of filtering is often implemented to ensure data integrity and proper lifecycle management. For example:

* You might not want to associate a CI that is already retired or in a failed state with a new change request originating from an incident.

* It helps guide users to select CIs that are relevant to the context of the originating Incident or Problem.

In conclusion, this reference qualifier dynamically adjusts the available CIs on your change records based on their origin, applying a specific operational status filter when the change is related to an Incident or Problem. To fully understand the exact operational statuses being excluded, you would need to examine the OpsStatusFilter script include in your ServiceNow instance.

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. 

 

 

VikMach
Mega Sage

@Sean Burton - You can run the following piece of code in your Background Script to understand what it does.
It filters the CI related to Incident and Problem which are not retired.

// Create a GlideRecord object for the cmdb_ci table
var gr = new GlideRecord('cmdb_ci');

// Check if the current record's class name is 'incident' or 'problem'
if (['incident', 'problem'].indexOf("incident" + '') !== -1) {
    // If it is, apply the operational status filter
    var opsStatusFilter = new OpsStatusFilter('cmdb_ci').by('CreateTask').join();
	gs.info("opsStatusFilter >> " + opsStatusFilter); // Operational Status Should not be "Retired"
    gr.addEncodedQuery('operational_statusNOT IN' + opsStatusFilter);
}

gr.setLimit(20); // Remove Limit to see all CI's
// Query the cmdb_ci table
gr.query();

// Process the results
while (gr.next()) {
    // Example: Output the sys_id and name of each CI
    gs.info('CI Sys ID: ' + gr.sys_id + ', Name: ' + gr.name);
}

 

Let me know if that helps.


Regards,
Vikas K