- 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 01:09 PM
It appears the g_form.getField is only available for Mobile. I need this functionality for Mobile and Desktop. Do you know a way I can do this for both UI Types?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 01:22 PM
If you set UI Type to All, it works for both. I don't think it is only supported for mobile as i have done this earlier.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 01:31 PM
- UI Type is set to All
- Isolate script is set to false
- Last message received from the following code snippet is "after clearing/before getfield"
Here is a snippet of the client script
g_form.addInfoMessage('before clearing');
g_form.setValue('variables.capacity_request_cpu', '[]');
g_form.addInfoMessage('after clearing/before getfield');
var my_var = g_form.getField('variables.capacity_request_cpu');
g_form.addInfoMessage('after getfield/before max_rows');
my_var.max_rows_size = 1; //allows upto 1. if you wnat more, incraes. i think max is 50
g_form.addInfoMessage('after max_rows');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 01:36 PM
use the MRVS name directly like this nad check.
var my_var = g_form.getField('capacity_request_cpu');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 01:39 PM
the script ends in the same location. Last message received is bolded below.
g_form.addInfoMessage('before clearing');
g_form.setValue('variables.capacity_request_cpu', '[]');
g_form.addInfoMessage('after clearing/before getfield');
var my_var = g_form.getField('capacity_request_cpu');
g_form.addInfoMessage('after getfield/before max_rows');
my_var.max_rows_size = 1; //allows upto 1. if you wnat more, incraes. i think max is 50
g_form.addInfoMessage('after max_rows');