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,

in the advanced reference qualifier you will have to call script include

Regards
Ankur

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

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

thanks Ankur , it works 

John160
Giga Contributor

Hi Ankur ,

Can you also help on this also 

Three levels of approval on PCR Project change request 1) PM 2) Business Sponsor and IT Lead. Both must approve. 2a) If a rejection occurs, notify pm 3) Manager of the "abc" group 3a) when approved occur, notify the PM Weekly notification that runs daily: Any approval that is 5, 10, 15, 20, 25, and 30 business days old, send an email to the Approver and copy the PM. NOTE: once Closed Incomplete, the PM should be able to set it back and resubmit the PCR once fixed. Most of it is done but getting some challenges on the schedule notification part

John160
Giga Contributor

Hi Ankur ,

Can you also help on this also

Three levels of approval on PCR Project change request 1) PM 2) Business Sponsor and IT Lead. Both must approve. 2a) If a rejection occurs, notify pm 3) Manager of the "abc" group 3a) when approved occur, notify the PM Weekly notification that runs daily: Any approval that is 5, 10, 15, 20, 25, and 30 business days old, send an email to the Approver and copy the PM. NOTE: once Closed Incomplete, the PM should be able to set it back and resubmit the PCR once fixed. Most of it is done but getting some challenges on the schedule notification part