The CreatorCon Call for Content is officially open! Get started here.

Best way to override TaskUtils Script Includes extension TaskUtilsSNC.getConfigurationItemFilter

Dharma Liyanag
Tera Guru

Hi There,

My requirement is the add table : change_request into this static variable CONSTANTS:

 

in TaskUtilsSNC  line 39.

    CONSTANTS: {
        OPS_FILTER_CLASSNAMES: ['incident', 'problem'], // task types for which the operational status filter will

 

And Override this function to use the changed one.

TaskUtilsSNC.getConfigurationItemFilter:

 

This will help to remove Retired CIs being shown on Configuration Item list in change_request.

 

Appreciate any advice.

Thanks!!

 

 

 

2 ACCEPTED SOLUTIONS

Dharma Liyanag
Tera Guru

This Works 🙂

 

var TaskUtils = Class.create();
TaskUtils.prototype = Object.extendsObject(TaskUtilsSNC, {

   /***************Custom changes****************/
   
    CONSTANTS: {
        OPS_FILTER_CLASSNAMES: ['incident', 'problem', 'change_request', 'change_task'], // task types for which the operational status filter will be applied      
    },
    getConfigurationItemFilter: function(current) {
        if (!current) {
            gs.error("[TaskUtilsSNC.getConfigurationItemFilter] : Invalid parameter");
            return;
        }

        var configItemFilter = '';
        var serviceOfferingFilter = 'sys_class_name!=service_offering';

        configItemFilter += serviceOfferingFilter;

        if (this.CONSTANTS.OPS_FILTER_CLASSNAMES.indexOf(current.sys_class_name + '') > -1)
            configItemFilter += "^operational_statusNOT IN" + new OpsStatusFilter('cmdb_ci').by('CreateTask').join();

        var principalClassFilter = this.getPCFilterEvaluated(current.sys_class_name + '');
        if (principalClassFilter.length > 0)
            configItemFilter += '^' + principalClassFilter;

        return configItemFilter;
    },

    type: 'TaskUtils'
});
 
 

View solution in original post

Stephen Anderso
Tera Expert

Thank you for this. Hi Support was not helpful for this solution

View solution in original post

2 REPLIES 2

Dharma Liyanag
Tera Guru

This Works 🙂

 

var TaskUtils = Class.create();
TaskUtils.prototype = Object.extendsObject(TaskUtilsSNC, {

   /***************Custom changes****************/
   
    CONSTANTS: {
        OPS_FILTER_CLASSNAMES: ['incident', 'problem', 'change_request', 'change_task'], // task types for which the operational status filter will be applied      
    },
    getConfigurationItemFilter: function(current) {
        if (!current) {
            gs.error("[TaskUtilsSNC.getConfigurationItemFilter] : Invalid parameter");
            return;
        }

        var configItemFilter = '';
        var serviceOfferingFilter = 'sys_class_name!=service_offering';

        configItemFilter += serviceOfferingFilter;

        if (this.CONSTANTS.OPS_FILTER_CLASSNAMES.indexOf(current.sys_class_name + '') > -1)
            configItemFilter += "^operational_statusNOT IN" + new OpsStatusFilter('cmdb_ci').by('CreateTask').join();

        var principalClassFilter = this.getPCFilterEvaluated(current.sys_class_name + '');
        if (principalClassFilter.length > 0)
            configItemFilter += '^' + principalClassFilter;

        return configItemFilter;
    },

    type: 'TaskUtils'
});
 
 

Stephen Anderso
Tera Expert

Thank you for this. Hi Support was not helpful for this solution