Reference qualifier is not working as expected.

Kumar147
Tera Contributor

I have two reference fields on a form. one is platform and second one is CMDB. CMDB is on task table. platform field is getting data from data management table and CMDB is getting data from cmdb_ci table. data management table having a list field which is reference to CMDB. when CMDB field is filled i need the reference qualifier to show only records related to that CMDB field. 
script include: 

var app = current.cmdb_ci;

var gr = new GlideRecord(‘table name);

gr.addQuery(‘u_applications’, app);

gr.query();

var result = [];

while(gr.next()){
result.push(gr.sys_id);

return result;

}

advanced ref qualifier : javascript: new script include name().function();

 

please help in this.

Thanks in advance

1 ACCEPTED SOLUTION

Hi @Kumar147 ,

 

You have not followed my instruction.

Not sure why you are writing script include.

 

Just add below code in your reference qualifier of plateform filed. nothing else is required.

 

javascript:'u_cmdb_listLIKE'+current.cmdb_ci

 

replace "u_cmdb_list" with your field name which present on your data management table.

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

View solution in original post

9 REPLIES 9

Najmuddin Mohd
Mega Sage

Hi @Kumar147 ,
Can you add a log message after var app = current.cmdb_ci, like 
gs.log('App value: ' + app);

I believe you cannot access current object in script include like you use current in business rule.

 

Possibly, you can pass the parameter current from the reference qualifier and return the results; like below

Qualifier: javascript: new script_include_name().function(current);

 

Script Include:

var MyScriptInclude = Class.create();
MyScriptInclude.prototype = {
    initialize: function() {},

    getRecords: function(current) {
        var app = current.cmdb_ci;
        var gr = new GlideRecord('table_name'); // Replace 'table_name' with the actual table name
        gr.addQuery('u_applications', app);
        gr.query();

        var result = [];
        while (gr.next()) {
            result.push(gr.sys_id.toString());
        }
        return result;
    },

    type: 'MyScriptInclude'
};



If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.

Hello @Najmuddin Mohd 

I have already tried removing current and passed the parameter in reference qualifier like javascript: new script include().function(current.cmdb); 

but noluck

Runjay Patel
Giga Sage

Hi @Kumar147 ,

 

Simply put the reference qualifier like below

 

javascript:'u_cmdb_listLIKE'+current.cmdb_ci

 

replace "u_cmdb_list" with your field name which present on your data management table.

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
LinkedIn: https://www.linkedin.com/in/runjay
YouTube: https://www.youtube.com/@RunjayP

-------------------------------------------------------------------------

 

Part 2. In this video i have talked about overview on ServiceNow platform/tool. How you can opt for personal dev instance (PDI)? how to login in ServiceNow instance and navigation to OOB modules. For document please visit: https://servicenowwithrunjay.com/ Follow Facebook page for latest update on

Hello @Runjay Patel,

I have tried this javascript: ‘u_app_platform=‘+current.cmdb_ci;

but not worked.