Dependent variable: Variable is dependent on number of users in list collector variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
Hello,
I have a list collector variable and an attachment variable. The attachment variable should only be visible and mandatory if the number of users in the list collector is more than 5.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
Use an onChange Catalog Client Script similar to this:
function onChange(control, oldValue, newValue, isLoading) {
var usrArr = newValue.split(',');
if (usrArr.length > 4) {
g_form.setDisplay('v_attachment', true); //attachment variable name
} else {
g_form.setDisplay('v_attachment', false);
This should also cover hiding the variable when the form loads, but if not create a similar onLoad Catalog Client Script, replacing newValue with g_form.getValue('user_list').split(',') where 'user_list' is the name of your list collector variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
please follow script shared by @Brad Bowman and that should solve your requirement.
💡 If my response helped, please mark it as correct ✔️ and close the thread 🔒 — this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader