- 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 12:10 PM
How are you disabling the Add button? I have set the max_rows property and still the Add button is available. It just removes the line. Is there a client script you are using to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 12:18 PM
If you set max_rows=2, once the user adds 2 rows to the mrvs, the "Add" button is automatically disabled.
Removing a single row by clicking the "X" or removing all by clicking the "Remove all" button will reactivate the "Add" button, but I do not know the script performing the reactivation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 12:17 PM
All our attempts returned an error when I tried to get the row count afterwards. So I used my article and reversed engineered it.
With this code it has row count 0:
g_form.setValue('variable_set_1', JSON.stringify([]));
Let me know if this works for your Add button as well! 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 12:21 PM
This did not re-enable the Add button either.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 11:40 AM
Hello
After removing the values.. you need to set the value for max_rows_size to a positive value for Add to be enabled.
Mark the comment as a correct answer and helpful if it helps.