Build a reference qualifier to show users who are not owners

Community Alums
Not applicable

Hi All,

 

Having a requirement that, 

On catalog form we have a fields like 

> Select the dl - (reference to DL table where we have owner, member) 

> Select user to add owner - reference to user table

 

here in the select user filed want to add a reference qualifer that validate the users data and show only the user who are not as owners of the selected Dl. 

 

Stucked here on proceeding further to how to keep this validation. Any suggestions. 

 

Thanks inadvance. 

1 ACCEPTED SOLUTION

J Siva
Tera Sage

Hi @Community Alums 
You can acheive this by using "sys_idNOT IN" operator in the ref qualifier.
1. Create one varibale to store the sys ids of the current owners (Hidden variable)

2. Create new variable and in the ref qualifier add the below script.

javascript:"active=true^sys_idNOT IN"+current.variables.approvers_sys_id;

 

Sample:

1. Catalog variables

JSiva_0-1742982762849.png

 

2. 

JSiva_1-1742982799000.png

3. Output:

JSiva_2-1742982850004.png

Hope this helps.
Regards,
Siva

 

View solution in original post

11 REPLIES 11

@Community Alums 

As per new community feature you can mark multiple responses as correct.

I believe I also answered your question correctly.

If my response helped please mark it correct as well so that it benefits future readers.

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

Community Alums
Not applicable

Hi @Ankur Bawiskar 

 

We tried to set the reference qualifier by using the script include and calling that in the reference qualifier like as below

Reference qualifier:

javascript: new fetchSMBmember().getDLNonOwners(current.variables.distribution_list_s);

 

Script include: 

getDLNonOwners: function(dl) {

        gs.log("DL Members start : " + dl);
        var owner1 = [];
        var owner2 = [];
        var owner3 = [];
        var gr = new GlideRecord('u_distribution_lists');
        gr.addQuery('sys_id', dl);
        gr.query();
        if (gr.next()) {
            // member1.push(gr.u_members.toString());
            owner1 = gr.u_dl_owner.toString().split(',');
        }
        gs.log("DL Members members list 1 : " + owner1);
        var gr1 = new GlideRecord('sys_user');
        gr1.addEncodedQuery('company=7b7db97087e4111012f263df8bbb35a0^active=true');
        gr1.query();
        while (gr1.next()) {
            owner2.push(gr1.sys_id.toString());
        }
        var memberList = new ArrayUtil();
        owner3 = memberList.diff(owner2, owner1);
        return 'sys_idIN' + owner3.toString();
    },
 
This is working as expected, but facing one issue on the retrieving the data. Its taking more time to response. 
chanti1_0-1743703012747.png

Before the form submission the response is taking more time and after submitting the request on the ritm its showing this error. 

 

Do you have any idea on this how to handle this.