Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Display variables n times based on another variable selection

Vaishali 11
Tera Guru

Hi,

 

I have a requirement where if a person selects number of person as 1/2/5, then there are a set of fields that should be visible for 5 times or so. Is this possible to do, if yes how it can be implemented?

 

Thanks in advance!!

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Vaishali 11 

you can use MRVS for this.

If user selected 2 let user fill 2 rows of MRVS

If user doesn't enter 2 rows, then you can validate this using onSubmit script.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

7 REPLIES 7

@Vaishali 11 

that's not what I mentioned if you read the above comment properly.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Community Alums
Not applicable

@Vaishali 11 ,

The approach shown in the image below is what Ankur is suggesting, which is logically sound if you want the same fields populated for all users. You can also add a condition in the onSubmit script so that if the user selects '2' as the number of persons, then 2 rows of the Multi-Row Variable Set (MRVS) are populated accordingly.

An alternative approach would be to create each variable 5 times (for example, if you need 3 fields per person - Name, Phone, Email - you'd need to create 3×5 = 15 variables total) and show/hide them based on the selected user count. However, this approach is tedious and not considered a good practice.

MIftikhar_0-1761221825603.png

 

Hi @Community Alums ,

I understood the logic Ankur is trying to say. But the field 'number of variable set' will be outside the MRVS and based on the selection of that field, the variable sets should be visible. So how exactly will this work?

 

Thanks in advance!!