To show the number of multirow variable set depending on selected value in normal variable.

Shweta Maurya
Tera Contributor

Requirement:-if condition1 met then need to allow Multirowvariableset1 row as 10 row only and Multirowvariableset2 row as 2 row only 

if condition2 met then need to allow Multirowvariableset1 row as 5 row only and Multirowvariableset2 row as 3 row only.

The condition above will be as normal variable in catalog form.

 

 

 

->I tried to write the script but its not working please help me with this

 

var CTAVisitWebsiteButton = g_form.getValue('visit_website_button_set'); // Multirow varaibale set name

    if (templatetype == "text" || templatetype == "media_image" || templatetype == "media_video" || templatetype == "media_doc"|| templatetype == "Media-Location") {

        alert("inside template");

        var len = CTAVisitWebsiteButton.getRow();
        for(var i = 0; i < len; i++) {
            inside("Inside for loop");
        var count = CTAVisitWebsiteButton.getRow(i);
        alert("count"  + count);
    }
            if (count > 2) {
                alert("inside row");
               
                g_form.addErrorMessage('You must fill less or equal 2 rows for this condition.'); // Display error message
                g_form.clearValue('CTAVisitWebsiteButton'); // Clear the field to force correction
            }
   

    //----------------

 

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@Shweta Maurya 

I don't think you can restrict the rows dynamically.

you can use onSubmit catalog client script and stop user from submission based on the validation and number of rows in MRVS

If my response helped please mark it correct and close the thread so that it benefits future readers.

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