Creating reference qualifier for CI field in Incident form

Filipp Fedorov
Kilo Guru

If a special service is selected I want to see only items that are related to that service so I made ref qual but it's not working.

Script Include

name: SAP_CI

Script: 

var SAP_CI = Class.create();
SAP_CI.prototype = {
    initialize: function() {},
    get_CI: function(service) {


        var ci = new GlideRecord('cmdb_ci');
        gs.log("I am workin", "Filipp");
        if (service == '3d2f748207381510b605ff208c1ed0c3') {

            gs.log("I am workin", script_includee);
            ci.addEncodedQuery('u_sap=true');
            ci.query();

        } else {
            ci.query();
        }
        answer = [];
        while (ci.next()) {
            answer.push(ci.getValue('sys_id'));

        }
    
        return 'sys_idIN' + answer;


    },

    type: 'SAP_CI'
};

Ref qual: javascript:  new SAP_CI().get_CI(current.business_service);

1 ACCEPTED SOLUTION

Filipp Fedorov
Kilo Guru

The reason was that I made changes in the task table not in dictionary override that's relate to incident

View solution in original post

5 REPLIES 5

Vaibhav Dane
Tera Expert
Tera Expert

Hi Filipp,

 

Can you please try "return 'sys_idIN' + answer.toString()" instead of "return 'sys_idIN' + answer";

 

Please mark correct if helpful.

 

Regards,

Vaibhav Dane

SumanthDosapati
Mega Sage
Mega Sage

Hi,

Try changing this

 answer.push(ci.getValue('sys_id'));

        }
    
        return 'sys_idIN' + answer;

TO

 answer.push(ci.sys_id.toString());

        }
    
        return 'sys_idIN' + answer;

 

Mark as correct and helpful if it solved your query.

Regards,
Sumanth

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

update as this and no script include would be required

javascript: var query = ''; if(current.business_service.toString() == '3d2f748207381510b605ff208c1ed0c3') query = 'u_sap=true'; query;

regards
Ankur

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

@Filipp Fedorov 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

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