To add extra record in multirow variable set based on checkbox selection.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
47m ago - last edited 46m ago
I have a multirow variable set named pack_size.
when user add value in multirow variable set without clicking rho1 checkbox and clicks Add button. That selected record will gets added in the multirow variable set. Eg:
If user add values and selects rho1 , and clicks Add , we should get two records. One should be the user input record and another record should contains:
How can we implement this.
I tried with OnSubmit script in the multirow variable set, but SG01 - BT Singapore record is not getting inserted.
Sharing with the OnSubmit script :
function onSubmit() {
alert('onSubmit triggered');
// RH01 checkbox checked?
var rh01 = g_form.getValue('rho1');
alert('RH01 Value: ' + rh01);
if (rh01 != 'true') {
alert('RH01 not checked');
return true;
}
alert('RH01 checked');
// Parent MRVS name
var mrvsName = 'pack_size';
alert('MRVS Name: ' + mrvsName);
// Parent form
var parentForm = g_service_catalog.parent;
alert('Parent form accessed');
// Existing MRVS rows
var mrvsValue = parentForm.getValue(mrvsName);
alert('Existing MRVS Raw Value: ' + mrvsValue);
var rows = [];
if (mrvsValue) {
try {
rows = JSON.parse(mrvsValue);
alert('JSON parsed successfully');
alert('Existing Rows Count: ' + rows.length);
} catch (e) {
alert('JSON Parse Error: ' + e);
rows = [];
}
} else {
alert('MRVS is empty');
}
// Add SG01 row
rows.push({
sales_organisation_addpack: 'SG01 - BT Singapore',
distribution_channel_addpack: 'RH - Regional Hub',
plant_addpack: 'RH01 - Regional Hub Direct',
storage_location_addpack: '101 - RH Direct - GEN'
});
alert('SG01 row added');
alert('Updated Rows Count: ' + rows.length);
// Update MRVS
parentForm.setValue(
mrvsName,
JSON.stringify(rows)
);
alert('MRVS updated successfully');
return true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12m ago
Hi @Amrutha K V ,
It is not recommended to create two records with a single click — one using the input value and another using the backend value.
For a better user experience, the end user should enter the value from the frontend, and the record should be created based on that input.
It would be better to ask the user to click the Add button in the MRVS once again if another record needs to be added.
