Set variable ReadOnly when Multi Row Variable Set not empty

SamuelChang
Tera Contributor

Hi all,

 

I need some help or guidance on how to set a variable Read-Only when the Multi Row Variable Sets (MRVS) not empty i.e. once it populated at least one item.


Basically, once I added Report Name & Email the field outside of MRVS should be set to Read-Only

SamuelChang_0-1722362720233.png

 

I've tried onLoad client script but it doesn't work quite right

function onLoad() {
	var mrvs = JSON.parse(g_form.getValue('report_name_and_email'));
	if(mrvs.length > 0) {
		g_form.setReadOnly('add_or_remove', true);
	}
}

Is there something else that I missed?

 

Thank you in advance!

17 REPLIES 17

Brian Lancaster
Tera Sage

I think this needs to be an onChange not an onLoad script. On Load script only run on form loads so once you are at the point were the MSRV is being filled out the form has already loaded. So it should be on change of the MSRV variable.

Brian,

 

Thank you for the quick response, I changed to onChange but doesn't seem to do the trick, did I miss something?

SamuelChang_0-1722364412007.png

 

Yes you cannot leave the variable name field blank. Hopefully you can select the multi-row variable set name.

Brian, 

I tried that but no luck so far, any other ideas?