How do I "Remove All" multirow variable set rows using a client script?

kevinharalson
Mega Expert

I need a client script for use in an onChange function to remove all rows from a multirow variable set.

Scenario

  1. A user will select a CI in a catalog item, and add maximum rows to a multirow variable set based on max_rows attribute.
  2. Then, the user realizes the wrong CI was selected, and changes the selected CI
  3. 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.

1 ACCEPTED SOLUTION
30 REPLIES 30

Would you have an example for setting the value for max_rows_size?

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.

 

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.

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.

 

If this has answered the question, kindly mark the comment as a correct answer so that the question is moved to the solved list.