How to restrict on add button of multi row variable set after some point

Akshaymhaske
Tera Contributor

Hi All,

 

i have added multi row variable set on record producer. but i want to restrict on add button of them once limit reached to 100% of one of the field. For more clarity please find below example.

in below snip multi row variable set-user added percentage values 20, 30 & 50 (highlighted in yellow) so total is 100%. Now we want to restrict user if he click on add button because % is already reached to 100%. 

 

Akshaymhaske_0-1692013450493.png

In short if sum of percentage column is reached 100 and user want to add more items then system need to prevent them when he clicked on add button with stating you can add upto 100 % not more than that.

or if he add 20, 30 and 60 then also system need to restrict user because sum is 110% that is above 100%.

 

Any inputs appreciated!

 

 

3 REPLIES 3

Peter Bodelier
Giga Sage

Hi @Akshaymhaske,

 

You could acomplish this using DOM manipulation in a catalog client script.

This worked for me:

 

function onLoad() {
	setTimeout(function () {
		var zAdd = this.document.getElementsByClassName("btn btn-primary m-r");
		var kAdd;
		for (kAdd = 0; kAdd < zAdd.length; kAdd++) {
			zAdd[kAdd].style.display = 'none';
		} 

	}, 500);
}

Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Hi @Peter Bodelier thank you for your inputs.

 

Using above dom we can hide and display add button. But what about percentage if we have 3 entries

20%, 30% & 60% then in this case total is above 100% that is 110. In such scenarios, we need to restrict user to submit or show some pop up with saying you can add upto 100% only.

 

Is there any way to achieve this

That may be a bit harder, since you do not have access to the rows. Maybe try using a client script on the rows to update a user preference that stores the percentage, and try to leverage that.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.