Variable Set with Client Script (onLoad)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 04:13 AM
Good morning! How do I get a value from within the multirow variable and send it to a variable that is not in the multirow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 04:25 AM
Do you want to do this after the MRVS is populated, like onLoad of the RITM/Catalog Task, or as each row of the MRVS is populated/edited, or wait until onSubmit of the record to ensure it is accurate with any row edits or deletions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 04:30 AM
As each row of the MRVS is populated/edited.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 01:35 PM
Since you want to do this with each MRVS row addition/edit, you can use an onSubmit Catalog Client Script like this that applies to the MRVS, not the Catalog Item:
function onSubmit() {
if (this) { //Service Portal method
this.cat_g_form.setValue('v_manager', 'Bob');
} else { //native UI method
parent.g_form.setValue('v_manager', 'Bob');
}
where 'v_manager' is the name of the Catalog Item variable. Note that this will replace the value with each row. If you want to append the value, use something like:
parent.g_form.setValue('v_manager', parent.g_form.getValue('v_manager') + ' Bob');
For the Service Portal method to work, you also need this onLoad Catalog Client Script that applies to the Catalog Item:
function onLoad() {
if (this) {//we only need to do this for Service Portal
//We need to make the g_form object for the parent item available from the MRVS window
this.cat_g_form = g_form;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 04:30 AM
Try this
function onLoad() {
// Get the multi-row variable (replace 'multirow_variable_name' with the actual name of the multi-row variable)
var multiRowVariable = g_form.getValue('multirow_variable_name');
// Assuming the multi-row variable is a list or an array, you can access specific values:
// Example: Retrieve the first row's value in a specific field (e.g., field 'item_name')
var firstRowItemName = multiRowVariable[0].item_name; // Replace 'item_name' with the actual field name in the multi-row
// Now, assign this value to another variable that is not in the multi-row (replace 'single_variable_name' with the actual variable name)
g_form.setValue('single_variable_name', firstRowItemName);
}