how to get variable set values in email script from flow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
32m ago
I am trying to read asset varibles from variable set. But it is coming as empty value with below script.
what is correct way to read array.object variable in email script. PFA for ref.
Email Script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
16m ago - last edited 11m ago
Hi @mrunalnikhi,
Your script looks right for a notification on sc_req_item, so the empty values usually come from one of these:
Internal names. mrvs_asset_details must be the Internal name on the multi-row variable set record, not its title. Each column (asset_tag, serial_number, mid and so on) must use the variable names inside the MRVS.
Timing. If the flow sends the email as soon as the RITM is created, the MRVS rows may not be saved yet. Move the Send Notification or Send Email step later in the flow, or add a short wait before it.
Check what arrives. Add this to the script and look at the system log:
gs.info('MRVS: ' + current.variables.mrvs_asset_details);
If the log shows the rows as JSON but your table is still empty, read them like this:
var rows = JSON.parse(current.variables.mrvs_asset_details.toString() || '[]');
for (var i = 0; i < rows.length; i++) {
var r = rows[i];
template.print('<tr><td>' + (i + 1) + '</td><td>' + r.asset_tag + '</td><td>' + r.serial_number + '</td><td>' + r.mid + '</td><td>' + r.emp_name + '</td><td>' + r.location + '</td><td>' + r.department + '</td><td>' + r.asset_type + '</td></tr>');
}
Reference variables such as location and department return sys_ids, so look up their display values if you need names.
If this helped, please mark it as the accepted solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
14m ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8m ago
I am in flow itself getting empty value? but on RITM I can see details under variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
14m ago
script looks fine to me
Did you print what came in logs?
gs.info('MRVS rows: ' + current.variables.mrvs_asset_details.getRowCount());
// also add this
gs.info('MRVS data: ' + JSON.stringify(current.variables.mrvs_asset_details));
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏