How to clear mrvs all row by on load client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2024 04:06 AM - edited 02-04-2024 04:08 AM
Hi,
How to clear mrvs/multi row variable set all row (all data) by on load client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2024 04:23 AM
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....

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2024 04:43 AM
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');