How to trigger function or client script the when delete the multi row variable set records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 01:43 AM
Hi All,
I want to trigger a function or client script when deleting the multi-row variable set records
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 07:34 AM - edited 08-31-2023 07:34 AM
This post may help give you an idea of how you can 'watch' the MRVS for changes. In this case you might have to update a hidden variable on the Catalog Item when this triggers, then use an onChange Catalog Client Script when that variable changes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 11:05 AM
I write the below script but its not triggering when i remove the records from mrvs
/* widget controller */
var c = this;
$rootScope.$on("field.change", function(evt, parms) {
var g_form = $scope.page.g_form;
if (parms.field.name == "test_value") // replace testing with the your MVRS internal name
{
if (g_form.getValue('test_value')) {
var rows = JSON.parse(g_form.getValue('test_value')); // replace testing with the your MVRS internal name
var sum = 0;
if (rows.length > 0) {
for (var i = 0; i < rows.length; i++) {
sum = parseInt(sum) + parseInt(rows[i].name) // replace your_field_name_to be_summed with your field name where your numbers to be added are stored
}
g_form.setValue('count', parseInt(sum)); // replace count with the variable back end name where you want to store the count of the MVRS rows
}
}
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 07:37 AM
you can detect the add/remove action
check this link
MRVS detect when a row is removed or deleted
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 10:59 AM
I wrote this below script in the widget its works only when the record is added but not trigger when i remove the records from mrvs