- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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.
Shashank Jain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Reference field can only have one value, you will have to change "requested for" variable to list collector for your requirement.
OR
Create new variable of list collector type, it can store multiple values. In case of "Minipay" multiple users can be selected and for others single user (this can be handled trough on change client script)
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Requested For is Reference or List collector?
If reference then you can anyhow select only 1 user.
Your requirement is not clear.
Share some screenshots.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello Ankur,
In below images as of now Requested for is Reference filed and able to select one option for all application .But my requirement is only for one application on tis catalog item.
suppose if i select Minipay application in Application field then in Requestor field able to select multiple user .For other applications it should normal as like now.
Due to this able to order multiple catalog item at time for multiple users.