Mutliple users select in requested for field choices

Manohararuna
Tera Contributor

Hello Everyone,

 

       I have one requirement. 

Requirement is In Catalog form having the Requestor For field (reference type--user table) and Application filed(reference type- App table) .If i select Minipay in Application then i am able to select multiple users in Requestor For field. This requirement only for Minipay option .suppose if i select another application then i am able to select single user at time in Requestor For field.

Please provide solution to this one.

 

Thanks,

Manohararuna

2 ACCEPTED SOLUTIONS

Rafael Batistot
Tera Sage

Hi @Manohararuna 

 

The Requested For variable in a catalog item is a reference type (to sys_user). Out-of-the-box, reference variables only allow one value. To allow multiple selections, you need to use a Lookup Select Box / Multi-row variable set / Glide List.

So the trick is:

  • You actually need two different variables:

    • requested_for_single → type = Reference (sys_user), for normal use.

    • requested_for_multi → type = Lookup Select Box (or Glide List), for Minipay.

  • Then use a Catalog Client Script (onChange of Application) to show/hide the right one.


Example Client Script

  • Type: Catalog Client Script

  • Applies to: Item

  • When: onChange → Application

 

 
 
function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    // If Application = Minipay
    if (g_form.getDisplayBox('application').value == 'Minipay') {
        g_form.setDisplay('requested_for_multi', true);
        g_form.setMandatory('requested_for_multi', true);

        g_form.setDisplay('requested_for_single', false);
        g_form.setMandatory('requested_for_single', false);
        g_form.clearValue('requested_for_single');
    } else {
        g_form.setDisplay('requested_for_single', true);
        g_form.setMandatory('requested_for_single', true);

        g_form.setDisplay('requested_for_multi', false);
        g_form.setMandatory('requested_for_multi', false);
        g_form.clearValue('requested_for_multi');
    }
}

View solution in original post

Shashank_Jain
Kilo Sage

@Manohararuna ,

 

  • Create Reference variable for single selection.

  • Create List Collector for multiple selection.

  • Control visibility via Client Script.

  • Only one will be shown at a time depending on Application selection.

 

 

 

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain

View solution in original post

5 REPLIES 5

Shashank_Jain
Kilo Sage

@Manohararuna ,

 

  • Create Reference variable for single selection.

  • Create List Collector for multiple selection.

  • Control visibility via Client Script.

  • Only one will be shown at a time depending on Application selection.

 

 

 

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain