Get list of users from another field

Souvick6917
Tera Contributor

Hello Experts,

 

I have a query. I want to set up a qualifier on a glide list type field. The users on the list will be same as users available on another glide list field present on another form.

Example : Form A contains Managers field , we have 3 records in this field. 

Form B contains Assigned to field. Only those 3 records from Managers field will be the available choices of this Assigned to field. From there we can choose any records. 

 

Please, if any help is well appreciated.

 

Regards'

Souvick 

 

Thanks in Advance 

5 REPLIES 5

J Siva
Tera Sage

Hi @Souvick6917 
Does Form B have a reference field that refers to a record from Form A?

If yes, the you can use below script in the ref qualifier of the field in Form 2.

javascript&colon;"sys_idIN"+<form 1 ref variable>.<field name from form 1>.toString();

 

JSiva_0-1743077149520.pngJSiva_1-1743077178132.png

 

Regards,
Siva

Robbie
Kilo Patron
Kilo Patron

Hi @Souvick6917,

 

There are a couple of ways to achieve this off the top of my head if I understand the 'ask' correctly.

The glide list field from Form B simply needs to have the same reference qualifier as the glide list field from form A. Eg users who's manager field is not empty.

Note, whilst the quick and easy way to implement would be to simply use the same simple qualifier configuration, if this will always be the same, I'd be inclined to leverage an advanced ref qualifier and call a script include.

By doing so it would mean you have one place to maintain this logic for these fields and any other that require the same logic moving forward.

 

Quick clarification question. Is this on the catalog or a task table related form such as incident etc. You could also use the same field as it were but use a dictionary overload to change the label etc.

 

Here's a quick link to configured the list field reference qualifiers including the simple and advanced options from the SN Docs site:

https://www.servicenow.com/docs/bundle/washingtondc-platform-administration/page/script/server-scrip...

 

To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.


Thanks, Robbie

sunil maddheshi
Tera Guru

@Souvick6917 

I think you can write advance reference qualifier and call script include on second form field:

 getManagerList: function(current) {
        var managerList = [];
        var gr = new GlideRecord('Form A Table Name'); 
        if (gr.get('sys_id', '<current.fieldNameWhichReferestoFormA>')) { /
            var managers = gr.getValue('u_managers'); // Replace with actual field name
            if (managers) {
                managerList = managers.split(','); // Managers field contains comma-separated sys_ids
            }
        }
        return 'sys_idIN'+managerList.toString().join(',');
    },

 

Call this function "getManagerList" in your reference qualifier:

javascript&colon; new ScriptIncludeName().getManagerList(current);

 

Please mark correct helpful if this helps you!

Ankur Bawiskar
Tera Patron
Tera Patron

@Souvick6917 

simply use this if on Form A you have a fieldA and within that there is a list field

javascript&colon;'sys_idIN' + current.formAField.listField.toString();

use this if on Form A you have a list field and within the same Form another field needs to be filtered based on above field

javascript&colon;'sys_idIN' + current.formAField.toString();

If my response helped please mark it correct and close the thread so that it benefits future readers.

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