The script include is not working for SC_task

YashasM
Tera Contributor

I am working on a SC task form where it has a reference type field that refers to "cmdb_ci" table . the task is to filterout the service option with status "retired" .there is a oob dictionary override , reference qualifier :javascript:new TaskUtils().getConfigurationItemFilter(current) ; so I have appended to this and created javascript:new TaskUtils().getConfigurationItemFilter(current) ;+"^ref_u_service_option.u_service_option_status!=3^ORsys_class_name!=u_service_option"; this is working but taking more than 40 seconds to load . so i tried to implement script include but this isn't working . Can you provide an approach to use .

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@YashasM 

your table seems to have huge records and hence taking time to load.

what optimization you did in your script?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

J Siva
Kilo Patron

HI @YashasM 

Please share your custom Script Include for validation.
Regards,
Siva

YashasM
Tera Contributor
var CIFilter = Class.create();
CIFilter.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    refer: function() {
        var ids = [];
        var gr = new GlideRecord('cmdb_ci');
        gr.addEncodedQuery('sys_class_name!=u_service_option^ORref_u_service_option.u_service_option_status!=3');
        gr.query();
        while (gr.next()) {
            ids.push(gr.getUniqueValue());
        }
       
        return ids.join(',');
    },

    type: 'CIFilter'
});

YashasM
Tera Contributor
var CIFilter = Class.create();
CIFilter.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    refer: function() {
        var ids = [];
        var gr = new GlideRecord('cmdb_ci');
        gr.addEncodedQuery('sys_class_name!=u_service_option^ORref_u_service_option.u_service_option_status!=3');
        gr.query();
        while (gr.next()) {
            ids.push(gr.getUniqueValue());
        }
       
        return ids.join(',');
    },

    type: 'CIFilter'
});

Ankur Bawiskar
Tera Patron

@YashasM 

your table seems to have huge records and hence taking time to load.

what optimization you did in your script?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader