Get List collector field values to a reference field

jitusingh
Tera Contributor

Hi everyone,

 

I have a 2 variables on a catalog item:

   1. Regulator - which is a reference field on the sys_user table

   2.  Coordinator - which is a list collector on the sys_user table

 

My requirement is Regulator could be anyone of the coordinator list. 

How to get the list collector value in a reference field?


I tried but not getting the right result - In a reference qualifier condition of the regulator I have put 
javascript:"active=true^sys_id="+current.variables.coordinator;



Thanks in advance for any help

1 ACCEPTED SOLUTION

maroon_byte
Mega Sage

A list collector field is a comma-separated field when you view the field content using glideRecord.

 

Keeping above in mind, you will have use:

javascript:"active=true^sys_idIN"+current.variables.coordinator;

View solution in original post

2 REPLIES 2

Deepak Shaerma
Kilo Sage

Hi @jitusingh 
create a catalog client script
Type: onChange()
Target Field: Coordinator

 

 var regulatorField = g_form.getControl('regulator');

    // Setting the dynamic reference qualifier
    if(regulatorField) {
        // newValue here holds the comma-separated sys_ids selected in the List Collector
        // Constructing a dynamic query for the reference qualifier
        var dynamicQuery = 'sys_idIN' + newValue;
        
        // Apply the dynamic reference qualifier
        g_form.getReferenceField('regulator').setAttribute(‘ref_qual_elements’, dynamicQuery);
        // You might need to reset the field to enforce the new qualifier
        g_form.clearValue('regulator');
    }

 

Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma 

maroon_byte
Mega Sage

A list collector field is a comma-separated field when you view the field content using glideRecord.

 

Keeping above in mind, you will have use:

javascript:"active=true^sys_idIN"+current.variables.coordinator;