Make MRVS fields mandatory based on a variable outside the MRVS (Country + No of Children)

GhitaB
Tera Expert

Hi ServiceNow Community,

I’m trying to achieve the following behavior in a catalog item (Service Portal / Employee Center) and would appreciate some guidance or confirmation of best practice.

 

I have:

  • A variable no_of_children (outside the MRVS)

  • A Multi-Row Variable Set called Children Information

    • name

    • child_last_name

    • child_s_date_of_birth

    • child_s_status

Expected behavior:

  • Only when Country = Italy AND no_of_children > 0

    • The MRVS fields above should be mandatory

    • Users should not be able to submit unless all fields in each row are filled

Is there A supported way to make MRVS row fields mandatory based on a variable outside the MRVS?

Thanks in advance for any insight or confirmation of best practice 🙏
Happy to share code snippets if needed.

1 REPLY 1

Ankur Bawiskar
Tera Patron

@GhitaB 

yes you can access outside variable in onLoad catalog client script which applies on MRVS

Syntax is this

var val = g_service_catalog.parent.getValue("no_of_children");

I created blog for this in past

Access value of catalog item variable within MRVS client 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