Record Producer: Keep previous MRVS rows when dropdown changes, and add new rows as extra columns (o
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sunday
Service Catalog → Record Producer → MRVS (Multi‑Row Variable Set)
Release:
(please add your release, e.g., Vancouver/Washington)
What I’m trying to do
On a Record Producer, I have a dropdown (select box). Based on the selected option, I populate a Multi‑Row Variable Set (MRVS) using an onChange Client Script.
My requirement is:
- When the user changes the dropdown again, the previously inserted MRVS data must remain, and
- The new selection should append additional data:
- Option A: Add the new data as additional columns to the same MRVS (if possible)
- Option B: If columns can’t be created dynamically, then show one more MRVS and keep all MRVS rows together in the same request submission
Finally, submit everything in a single request.
What I already do
- I populate the MRVS rows on dropdown onChange using client script (g_form) with JSON.
- The MRVS repopulates correctly for the current selection, but when selection changes, previous rows are lost.
- I’m looking for a clean pattern to merge previous rows with new rows and guidance on columns vs extra MRVS.
Questions
- What is the recommended pattern to retain previous MRVS rows and append rows for the new selection?
- Can MRVS columns be added dynamically at runtime? If not, what is the best design (single MRVS with superset columns + conditional show/hide, or multiple MRVS)?
- Best practice to merge MRVS JSON values on client side (without server round‑trip) and to load option‑specific rows via GlideAjax when needed?
- Any caveats for UI Policies / Catalog Client Scripts with MRVS JSON?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
1. MRVS column can not be by dynamically created
2.MRVS is also can not be dynamically created too. By my understanding, if you want 2 MRVS, 1st always shows, 2nd only shows when the the dropdown is changed. Then
-Create a hidden boolean as the condition for when the 2nd MRVS will show up. Conditioning that boolean by the dropdown to hide or show the 2nd MRVS
-You can get the whole MRVS by using g_form.getvalue('*mrvs_name*'). it will be a json string containing the MRVS data. You can use JSON.parse() it to manipulate the old MRVS data whatever you like then stringify it back to json string.
-Then you can simple g_form.setvalue('*mrvs2_name*', *json_string*) to set the 2nd MRVS to all the 1st MRVS data
var mrvs1_Datastr = JSON.parse(g_form.getValue('mrvs1'));
// Manipulate by your choice
//
var stringified_data = JSON.stringify(mrvs1_Datastr);
g_form.setValue('mrvs2', stringified_data);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
It would be extremely helpful and beneficial to you to show your existing onChange script as a starting point, and screenshots of your MRVS. I take your continued use of the word 'column' to mean 'row', though since you use both, your intention is unclear. All variables within a MRVS will show as columns when the MRVS is displayed, but you can hide certain variables in the add/edit dialog window based on the value of a variable in the Record Producer, but since you're populating it dynamically on change of a variable, I don't even see how this is relevant. In any event, here's an example of how you can set the value of a MRVS on change - whether it's the initial value the first time the variable is set, or appending rows each subsequent time the variable is updated.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var mrvsArr = [];
//if MRVS values exist, add them to the array
var mrvs = g_form.getValue('managers_mrvs'); //internal name of MRVS
if (mrvs.length > 2) { //native UI returns [] for empty MRVS value which causes a parsing error
mrvsArr = JSON.parse(mrvs);
}
//populate the MRVS array with new/additional rows
mrvsArr.push({
"v_manager_mrvs" : g_form.getValue('v_employee_mrvs') //add a comma then a row for each variable to populate
});
//update the MRVS value from the array
g_form.setValue('managers_mrvs', JSON.stringify(mrvsArr));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
HI Brad, Thanks for providing the solution:
My requirement is this one:
I am working on a Record Producer where I have a dropdown field, and based on the selected option, I populate a Multi‑Row Variable Set (MRVS). The MRVS loads correctly for the first selection, but when the user changes the dropdown, the previously added MRVS rows disappear because they get overwritten. My requirement is to retain all previously added MRVS rows and append the new rows whenever the dropdown value changes, so that nothing is lost.
I also understand that MRVS cannot add new columns dynamically at runtime, so if expanding columns is not possible, I am fine with showing another MRVS for the second selection while keeping all MRVS data together in a single request submission. Currently, I am populating MRVS using JSON with g_form (the standard way of handling MRVS values), and I plan to use Glide Ajax to fetch data from different tables for each dropdown option.
I would appreciate guidance on the best approach to retain previous MRVS rows, merge or append new rows, and manage this setup cleanly using UI Policies or Catalog Client Scripts. Any recommended pattern or example would be very helpful.
Here one more major thing is we need to populate the MRVS based on the different tables,
Like on selection of Dropdown option we need to populate one MVRS related fields, We need to stay visible & add one MVRS below based on the same Dropdown option change. as per your Above solution we are getting new array each time we are loosing the previously selected option.
Like that we have 14 Options we need do in that few are having the same MRVS set. at that time we need make addition things.
Could you please provide your inputs on that is most help full to me.
Thanks,
Azeez.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
The solution I provided meets this requirement by first retrieving any existing MRVS values before adding the new values to the same array, which is then used to set the value of the MRVS.
