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.

How to set the minimum number of rows in MRVS

KS18
Giga Guru

I know how to set the maximum number of rows in MRVS.
that is setting "max_rows=X" in Variable Set Attributes.
Then, can I set the minimum number of rows?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

if you want minimum 1 row then you can use Catalog UI policy and make MRVS as mandatory

OR

you can use onLoad catalog client script

g_form.setMandatory('mrvs_name', true);

But if more than 1 minimum row then script

you need to use onSubmit catalog client script and check that

I took example that is minimum 2 rows is required

function onSubmit(){

	var json = g_form.getValue('mrvsVariableSetName');
	var parser = JSON.parse(json);
	var len = parser.length;
	if(len < 2){
		alert('Please give minimum 2 rows');
		return false;
	}

}

Regards
Ankur

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

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

if you want minimum 1 row then you can use Catalog UI policy and make MRVS as mandatory

OR

you can use onLoad catalog client script

g_form.setMandatory('mrvs_name', true);

But if more than 1 minimum row then script

you need to use onSubmit catalog client script and check that

I took example that is minimum 2 rows is required

function onSubmit(){

	var json = g_form.getValue('mrvsVariableSetName');
	var parser = JSON.parse(json);
	var len = parser.length;
	if(len < 2){
		alert('Please give minimum 2 rows');
		return false;
	}

}

Regards
Ankur

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