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.

Conflict Between Dictionary Override Reference Qualifier and Script Include Logic

mihirgupta
Tera Contributor

Subject: Dictionary Override – Reference Qualifier blocking custom Script Include logic for filtering Department field. 

Hi all,

I’m working on a use case in ServiceNow involving the cmdb_ci_business_app table.

In this table, there are two reference fields:

Business Unit: references the Business Unit table.

Department: references the Department table.

In the Department table, there’s also a Business Unit reference field.

The requirement is:
When a user selects a Business Unit in the cmdb_ci_business_app form, the Department field should display only those departments that are associated with that selected Business Unit.

I’ve created a Dictionary Override for the Business unit field (specific to the cmdb_ci_business_app table) and checked the Override reference qualifier option.
My custom reference qualifier script is:


javascript: new getbuSubdivision().showbuSubdivs(current.getValue('business_unit'));

 

Now, i wrote Script include, so that i can apply a restriction on department field in business app table:

Script Include:

var getbuSubdivision = Class.create();

getbuSubdivision.prototype = {

    showbuSubdivs: function(bUnit) {

        //gs.info("Mihir Testing");

        var subDivisions = [];

        var gr = new GlideRecord('cmn_department');

        gr.addEncodedQuery('parent=NULL^code=APMSUBBU^business_unit='+bUnit);

        gr.query();

        while (gr.next()) {

            subDivisions.push(gr.getValue('name'));

        }

        return 'sys_idIN' + subDivisions.toString();

    },

    initialize: function() {

    },

    type: 'getbuSubdivision'

};

but as a Dictionary Override on the Business Unit field of cmdb_ci_business_app.

Then suddenly your Business Unit field itself stopped showing records.

i can’t see any business unit records in business unit field. i unable to select any of the records from business unit field. 

Let us understand with attached snaps: what is the exact requirement:

1 ACCEPTED SOLUTION

M Iftikhar
Tera Sage

Hi @mihirgupta,

 

Could you clarify why you're applying the reference qualifier on the Business Unit field? If you're looking to filter by department, the reference qualifier should actually be applied to the Department field.

 

Additionally, there's already an out-of-the-box (OOTB) Dictionary Override on the cmdb_ci_business_app table's Department field, which is handling the same functionality.

MIftikhar_0-1759940045971.png

Dictionary Override Link: 

https://<your-instance>.service-now.com/sys_dictionary_override.do?sys_id=56b02b853b201300a70fe79c83...

 

If my response helped, please mark it as the accepted solution so others can benefit as well.

 

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.

View solution in original post

3 REPLIES 3

M Iftikhar
Tera Sage

Hi @mihirgupta,

 

Could you clarify why you're applying the reference qualifier on the Business Unit field? If you're looking to filter by department, the reference qualifier should actually be applied to the Department field.

 

Additionally, there's already an out-of-the-box (OOTB) Dictionary Override on the cmdb_ci_business_app table's Department field, which is handling the same functionality.

MIftikhar_0-1759940045971.png

Dictionary Override Link: 

https://<your-instance>.service-now.com/sys_dictionary_override.do?sys_id=56b02b853b201300a70fe79c83...

 

If my response helped, please mark it as the accepted solution so others can benefit as well.

 

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.

thanks for the quick reply SIr..Actually, after posting, I realized that I should have used the reference qualifier in the Department field instead of the Business Unit field. Anyway, I’ve corrected the configuration now. As per the stakeholder’s requirement, I need to display restricted records that’s why the reference qualifier needs to be updated.