- 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 11:57 AM
Would you have an example for setting the value for max_rows_size?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 12:20 PM
Try liek this. After you clear the MRVS in the same script, add these 2 lines.
var my_var = g_form.getField("MRVS name");
my_var.max_rows_size = 5; //allows upto 5. if you wnat more, incraes. i think max is 50
Mark the comment as a correct answer and also helpful once worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 12:29 PM
I misunderstood. A max_rows attribute is defined as needed on the MRVS. I am needing to re-enable the Add button in my client script once the rows have been removed from the MRVS.
If you set max_rows=2, once the user adds 2 rows to the mrvs, the "Add" button is automatically disabled.
Then, if the user removes a single row by clicking the "X" or removes all rows by clicking the "Remove all" button, the Add button will be re-enabled for use. But, if I remove the data rows using a client script, the Add button remains inactive.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 12:34 PM
Thats correct.
Since you are resetting the values of the MRVS through script without using remove all, SN does not know that the rows are cleared, event though they are removed form the UI. Hence you need to set the value max_rows_size also to enable the Add button.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 12:51 PM
If this has answered the question, kindly mark the comment as a correct answer so that the question is moved to the solved list.