- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 09:50 AM
I need a client script for use in an onChange function to remove all rows from a multirow variable set.
Scenario
- A user will select a CI in a catalog item, and add maximum rows to a multirow variable set based on max_rows attribute.
- Then, the user realizes the wrong CI was selected, and changes the selected CI
- Upon selection of a new CI, I need a client script to remove all rows from the multirow variable set and enable the "Add" button.
I have tried the following without success
- g_form.setValue(< mrvs name>, '');
- g_form.setValue(< mrvs name>, '[]');
- g_form.clearValue(< mrvs name>);
In all instances the information is removed, but the "Add" button remains disabled.
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 04:23 PM
I got it working guys!
As it is a bit much I have written an article on it:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 02:32 PM
okay, backend i have to verify once. may be i checked only in SP.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 04:23 PM
I got it working guys!
As it is a bit much I have written an article on it:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2020 05:14 PM
Hope you are doing well.
Is your question resolved? Or do we need to follow-up on this?
Please mark the answer as correct if it solves your question. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.
Kind regards,
Willem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2020 09:11 AM
I was out of the office last week, but I had not found a resolution as of my departure.
I have not been able to review and test your lastest post from 10 days ago.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2020 02:49 PM
Thank you! The function worked for me, but I adjusted it a little to preserve and reuse the original max_rows value. This will allow the max_rows to be adjusted on the MRVS without having to revisit the client script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
try { // try in service portal.
var field = g_form.getField("variable_set_1");
if (field != null) {
var max_rows = field.max_rows_size;
g_form.setValue('variable_set_1', JSON.stringify([]));
field.max_rows_size = max_rows;
}
}
catch(e){ //desktop
function clearRows (sysIdMRWS) {
TableVariableService.removeAllRows(sysIdMRWS);
}
clearRows("variable_set_id");
}
}