Dynamic filter to get One of my child accounts / companies

Nithin21
Tera Expert

OOB there is a dynamic filter to get one of my company.

This filter uses the function getCompanyID(), which returns the company of the login user.

 

To be used in reports on Case, how to get my account as well as child accounts tagged to my account

 

https://dev****.service-now.com/nav_to.do?uri=%2Fsys_filter_option_dynamic.do%3Fsys_id%3D8b5bbcfd0ff...

find_real_file.png

 

 

 

2 REPLIES 2

Tony Chatfield1
Kilo Patron
Hi, you may need to clarify exactly what you mean by 'child accounts tagged to my acccount'. Does 'my account' mean the company assigned/applied to your user record? If yes, then I don't recall the company table having a parent/child relationship OOB? What is your parent/child relationship? and what is the context of 'tagged'

Nithin21
Tera Expert

Parent / Child Account is defined as shown below 

Refer to the column "Parent Account"

 

find_real_file.png

 

Impersonate Julie Lewis,
Go to Case -> Add filter -> Account (is) One of My Accounts

Expected:
All the BOXEO accounts are added in the filter
Julie is able to see the cases raised for ALL Boxeo accounts

 

 

The below script returns the expected list of accounts:

        var childAccount = [];
        var loginCompany = '';

        var getMyAccount = new GlideRecord('sys_user');
        getMyAccount.addQuery('sys_id', gs.getUserID());
        getMyAccount.query();
        if (getMyAccount.next()) {
            loginCompany = getMyAccount.company;
        }

        var getParentChildAccount = new GlideRecord('customer_account');
        getParentChildAccount.addEncodedQuery('account_parent=' + loginCompany + '^ORsys_id=' + loginCompany);
        getParentChildAccount.query();
        while (getParentChildAccount.next()) {
           childAccount.push(getParentChildAccount.sys_id);
        }
		
		return childAccount;

 

Dynamic Filter is setup as shown below 

find_real_file.png

 

 

Result:

In Case table, i see the filter is showing as empty

 

find_real_file.png