How to tell if I'm adding a new row or editing a row in a multi-row variable set (MRVS) with g_form

Mark Endsley
Tera Guru

Is there any way using g_form or any other client side object to tell when a MRVS row is opened either by using the pencil or clicking add? I notice the header at the top is different.

MarkEndsley_1-1700148496731.png

 



MarkEndsley_0-1700148482122.png

 

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

I'd like to see if others have a solution based on the behind the scenes inner-workings, but this approach backs into it. 

 

An onLoad Catalog Client Script that applies to the MRVS will run when adding or editing a row.  If any variables contain a value, then you must be editing the row.  This would be more certain if you have at least one mandatory variable, to prevent a false positive if some yahoo adds an empty row, but you get the idea.  

Thanks Brad,

 

At this point I've solved the problem by restructuring my UI policies. 

What you are suggesting could work, but it wouldn't be a very elegant solution. Curious if anyone knows of another way.

If you're up for some verboten DOM manipulation, you can create a script like this that applies to the Variable Set. The else if is overkill as there are only two options, but it shows the attibute of both buttons.  Note that this will not work in Service Portal or Employee Center.

function onLoad() {
	var btn = this.document.getElementsByClassName("btn btn-primary dialog-buttons");
	if (btn[0].innerText == 'Add') {
		alert('You are adding a row');
	} else if (btn[0].innerText == 'Save') {
		alert('You are editing a row');
	}
}