Remove Multirow Variable Set Rows based on a variable in the row

Dillin  Bradley
Tera Expert

Hello!

 

Im looking to remove rows in a multirow variable set upon submission of a Catalog item but only for rows that have a "No" in a yes/no variable.

 

I have a MRVS that populates data from one variable. the end user would only make changes to rows that need changed and un change the field "Changing" goes from No to Yes. When they submit i would like all the rows that have a No value in the "Changing Field.

 

Here is screenshot. I would like the 3 middle lines to be deleted upon submission, leaving only the top and bottom in this case

 

DillinBradley_1-1676486149343.png

 

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

A Catalog Client Script like this will re-populate the MRVS with only the Yes rows:

function onSubmit() {
	var newObjArr = [];
	var obj = JSON.parse(g_form.getValue('market_information')); //internal name of MRVS
	for (var i=0; i<obj.length; i++) {
		if (obj[i].changing == 'Yes') {
			newObjArr.push({
				restaurant: obj[i].restaurant,
				director: obj[i].director,
				changing: obj[i].changing,
			});
		}
	g_form.setValue('market_information', JSON.stringify(newObjArr));
	}
}

with your MRVS internal name, and the name of every MRVS variable in the newObjArr push.