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.

 Business Unit table

John160
Giga Contributor

Hello all , 

I have to filter the values showing in a list type field which is referring to Business Unit table. I don't want to show those values which are parent to any other BU. It means if a BU has a child then only the child BU should be available and not the parent one

1 ACCEPTED SOLUTION

Hi,

Something like this

Script Include:

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

    getRecords: function(){

        var arr = [];
        var gr = new GlideRecord("bu table"); // use valid table name here
        gr.query();
        while(gr.next()) {
            var gr1 = new GlideRecord("bu table"); // use valid table name here
            gr1.addQuery("parent", gr.sys_id); // use valid parent field here
            gr1.query();
            if (!gr1.next()) {
                arr.push(gr.sys_id.toString());
            }
        }

        return arr.toString();

    },

    type: 'CheckRecords'
};

How to call in reference qualifier

javascript: 'sys_idIN' + new CheckRecords().getRecords();

Regards
Ankur

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

View solution in original post

14 REPLIES 14

Hi Ankur ,

List Field is on demand amd Project table/form. It refers to bu table so parent child relationship is oob. Yes correct, no BU which has a child, if child only child should appear
 
 

Hi John,

I wanted to check how you are identifying relationship between child and parent BU

List field is on demand table and refers BU table.

Example: BU001 is parent of BU002 so which field on BU says BU002's parent is BU001

Any field?

Regards
Ankur

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

Hi Ankur i didnt get the question , can you please elaborate ?

This is how a BU looks like. Here for example, Asia is parent of Asia 2nd. So if I click on magnifying glass to select a BU, I don't want Asia to appear on that list because it is parent of other BU.

find_real_file.pngThis is how a BU looks like. Here for example, Asia is parent of Asia 2nd. So if I click on magnifying glass to select a BU, I don't want Asia to appear on that list because it is parent of other BU.