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

okay. can you check browser console and see if you are getting any error there

 

com.glideapp.servicecatalog_cat_item_view.do?v=1&sysparm_id=4ba269eb1bd59c501462ececbc4bcb32&sysparm_link_parent=0753dcfe4f8e02400e20650f0310c766&sysparm_catalog=b6d4f9504ffdca000e20650f0310c781&sysparm_catalog_view=catalog_*****_technical:1094 Uncaught TypeError: g_form.getField is not a function
at h_f8a2c4841b5b14101462ececbc4bcbf0 (com.glideapp.servicecatalog_cat_item_view.do?v=1&sysparm_id=4ba269eb1bd59c501462ececbc4bcb32&sysparm_link_parent=0753dcfe4f8e02400e20650f0310c766&sysparm_catalog=b6d4f9504ffdca000e20650f0310c781&sysparm_catalog_view=catalog_*****_technical:1094)
at doCatOnChange (js_includes_catalog.jsx?v=08-05-2020_0901&lp=Wed_Sep_09_08_36_25_PDT_2020&c=13_457:616)
at variableOnChange (js_includes_catalog.jsx?v=08-05-2020_0901&lp=Wed_Sep_09_08_36_25_PDT_2020&c=13_457:554)
at HTMLInputElement.onchange (com.glideapp.servicecatalog_cat_item_view.do?v=1&sysparm_id=4ba269eb1bd59c501462ececbc4bcb32&sysparm_link_parent=0753dcfe4f8e02400e20650f0310c766&sysparm_catalog=b6d4f9504ffdca000e20650f0310c781&sysparm_catalog_view=catalog_*****_technical:525)
at callOnChange (js_includes_last_doctype.jsx?v=08-05-2020_0901&lp=Wed_Sep_09_08_36_25_PDT_2020&c=13_457:6222)
at e.referenceSelect (js_includes_doctype.jsx?v=08-05-2020_0901&lp=Wed_Sep_09_08_36_25_PDT_2020&c=13_457:22415)
at e.select (js_includes_doctype.jsx?v=08-05-2020_0901&lp=Wed_Sep_09_08_36_25_PDT_2020&c=13_457:22389)
at e.onMouseUp (js_includes_doctype.jsx?v=08-05-2020_0901&lp=Wed_Sep_09_08_36_25_PDT_2020&c=13_457:22476)

Okay. Check out the article of Willem. 

Mark my comment(s) as helpful if they had helped you.

Here it is listed as mobile only. Not an official source though.. https://sn.jace.pro/docs/scripting/glideform/#desktop-getcontrol You got this working in back end @asifnoor

Don't know that I have already mentioned this, but I have also tried the following.

Where 'b919a58b1b32dc10c1ff4159cc4bcbb4Add' is the element ID of the Add button.

g_form.setValue('variables.capacity_request_cpu', '[]');
g_form.setDisabled('b919a58b1b32dc10c1ff4159cc4bcbb4Add', false);