Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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. 

Vishal Birajdar
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
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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader