The CreatorCon Call for Content is officially open! Get started here.

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:

0 REPLIES 0