We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Reference qualifier not working as expected

Yasin Shaik11
Tera Contributor

Hi All,

 

Need help for the below. 

 

In custom table we have a company and department reference fields. Here whenever user selects the company like for example user select the company of ACME Japan then I want to show Department records which are associated with the company of the ACME Japan company those departments like HR and IT and customer support. For that I have implemented a Advanced reference qualifier on Department field as follows. But this is not working as expected.  and also, whenever i save the dictionary record of Department field immediately advanced option gets removed and shows only simple qualifier and when i change it to advanced then i can be able to see the script which i have mentioned as below. is this normal behavior? Please confirm. 

 

Use reference qualifier : Advanced. 
 

 

Reference qual : Javascript:new DepartmentValues().FilterDepartment(current.company);

 

 

FilterDepartmentfunction(currentRecord) {

        gs.log('DEP001'+currentRecord); // name

        var company = currentRecord.name; 

        var DepartmentGr = new GlideRecord('cmn_department');
        DepartmentGr.addQuery('company', company);
        DepartmentGr.query();

        var departmentLIst = [];

        while (DepartmentGr.next()) {

            departmentLIst.push(DepartmentGr.name);

        }

        var departmentFilter = departmentLIst.join(',');

        return departmentFilter;

        gs.log('DEP002' + departmentFilter);


    },



8 REPLIES 8

Hi @Yasin Shaik11 

 

Make put this reference qualifier

 

javascript:'company='+current.u_administrator_company;

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

I have tried with but its not working and i can able to see the all the department values in department field as attched. 

VishalB06557037
Giga Sage

Hi @Yasin Shaik11 

 

In Reference qualifier you can put below code
 
javascript:"company=" + current.getValue("company");
 
 
Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Ankur Bawiskar
Tera Patron

@Yasin Shaik11 

you can use advanced ref qualifier and script include is not required

something like this

javascript:'company=' + current.company;

If my response helped please mark it correct and close the thread so that it benefits future readers.

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