take table data from widget and add to RITM and SCTASK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
hi everyone,
I've created a simple and dynamic widget to use on the service portal so that users can add info into each row and copy rows as needed (like a multi-row but with the ability to duplicate rows). but when the catalog item is submitted, the RITM does not include the widget with the table and data, and it's also not appearing on the task generated.
how do I get widget data to appear in my RITM and SCTASK records? And can I also get that widget data into an email notification as a table??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @C-G ,
When you use a custom widget in a catalog item, its data isn’t automatically stored with the RITM — you have to explicitly pass it to the record.
Steps to make it work:
1. Store widget data in a variable
Use a hidden variable in the catalog item, e.g. u_widget_data.
From your widget’s client controller, before submission, set the variable value:
$scope.data.u_widget_data = JSON.stringify($scope.rows); // rows = your table data
Then use:
g_form.setValue('u_widget_data', JSON.stringify($scope.rows));
This ensures the data is submitted along with the form.
2. Copy data from variable to RITM & SCTASK
Use a Flow Designer or Business Rule on sc_req_item:
(function executeRule(current, previous) {
var data = current.variables.u_widget_data;
if (!data)
return;
// Example: store parsed JSON in a field or use it in SCTASK creation
var tasks = JSON.parse(data);
// You can also set current.description = data; or insert to a child table
})(current, previous);
If you’re generating Catalog Tasks, use a Run Script action in the flow to copy that same variable to sc_task.description or a custom field.
3. Show data in email notifications
In your notification email, use a mail script to parse the JSON and build an HTML table:
(function() {
var result = '';
var data = current.variables.u_widget_data;
if (!data) {
result = 'No data submitted.';
} else {
var rows = JSON.parse(data);
result += '<table border="1" style="border-collapse:collapse;width:100%;">';
result += '<tr><th>Column1</th><th>Column2</th></tr>';
rows.forEach(function(row) {
result += '<tr><td>' + row.col1 + '</td><td>' + row.col2 + '</td></tr>';
});
result += '</table>';
}
template.print(result);
})();
Then reference it in the email body:
${mail_script:widget_table_display}
Summary :
Use a hidden variable to capture widget data (JSON).
Copy it to RITM/SCTASK using BR or Flow.
Render it in notifications using a mail script.
Thanks!