Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

MRVS issues

SandeepKSingh
Kilo Sage

How to add rows dynamically in Multi Row Variable set (MRVS) based on input value of Catalog item ??

3 ACCEPTED SOLUTIONS

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @SandeepKSingh 

 

refer this:

 

https://www.servicenow.com/community/developer-articles/how-to-add-rows-dynamically-in-multi-row-var...

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

View solution in original post

Ravi Gaurav
Giga Sage
Giga Sage

Hi @SandeepKSingh 

You can achieve this with an onChange Catalog Client Script on the numeric field (e.g., No. of Companies Worked).
When the value changes, dynamically build and set the MRVS JSON using g_form.setValue().

Example:

 
function onChange(control, oldValue, newValue, isLoading) { if (isLoading || !newValue || isNaN(newValue)) return; var rows = []; for (var i = 0; i < newValue; i++) { rows.push({ company: "", position: "", start_date: "", end_date: "" }); } g_form.setValue("employment_details", JSON.stringify(rows)); }
  • employment_details is the internal name of your MRVS.

  • This creates the specified number of blank rows automatically when the user enters a number.

 
 
--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

Ravi Gaurav
Giga Sage
Giga Sage

@SandeepKSingh 

Below Article work !!
https://www.servicenow.com/community/developer-articles/how-to-add-rows-dynamically-in-multi-row-var...

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

4 REPLIES 4

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @SandeepKSingh 

 

refer this:

 

https://www.servicenow.com/community/developer-articles/how-to-add-rows-dynamically-in-multi-row-var...

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron
Tera Patron

@SandeepKSingh 

what did you start with and where are you stuck?

these links should help you

How to add rows in multi row variable set based on variable choice order 

How to add rows dynamically in Multi Row Variable set (MRVS) based on input value of Catalog item

💡 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

Ravi Gaurav
Giga Sage
Giga Sage

Hi @SandeepKSingh 

You can achieve this with an onChange Catalog Client Script on the numeric field (e.g., No. of Companies Worked).
When the value changes, dynamically build and set the MRVS JSON using g_form.setValue().

Example:

 
function onChange(control, oldValue, newValue, isLoading) { if (isLoading || !newValue || isNaN(newValue)) return; var rows = []; for (var i = 0; i < newValue; i++) { rows.push({ company: "", position: "", start_date: "", end_date: "" }); } g_form.setValue("employment_details", JSON.stringify(rows)); }
  • employment_details is the internal name of your MRVS.

  • This creates the specified number of blank rows automatically when the user enters a number.

 
 
--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

Ravi Gaurav
Giga Sage
Giga Sage

@SandeepKSingh 

Below Article work !!
https://www.servicenow.com/community/developer-articles/how-to-add-rows-dynamically-in-multi-row-var...

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/