How to clear mrvs all row by on load client script

Chandra18
Mega Sage

Hi, 

How to clear mrvs/multi row variable set all row (all data) by on load client script. 

2 REPLIES 2

Sohail Khilji
Kilo Patron
Kilo Patron

 

Try this :

 

function onLoad() {
	if (isLoading || newValue == '') {
		return;
	}
	try { // try in service portal.
		var field = g_form.getField("variable_set_1");
		if (field != null) {
			g_form.setValue('variable_set_1', JSON.stringify([]));
			field.max_rows_size = 3;
		}
	}
	catch(e){ //desktop
			function clearRows (sysIdMRWS) {
					TableVariableService.removeAllRows(sysIdMRWS);
			}
			clearRows("variable_set_id");
	}
}

 

Thanks,

Sohail Khilji


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

OlaN
Giga Sage
Giga Sage

Hi,

Not sure why you would want to clear a variable in an onLoad script. If this would happen on the service portal, it should be an empty variable already if the (for example) Catalog item is loading.

If this is to be when an agent opens the RITM or SCTASK at back-end, why would you want to automatically clear out existing variable data at load time?

 

Anyhow, you should be able to do it with a simple:

g_form.clearValue('your_variable_name');