- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2021 05:05 AM
Hello,
I have created a record producer with two variable set, one of it is multi-row variable set. I wanted to update a variable outside my multi row variable set, I am not able to do it on the service portal, but it's working on the backend.
I have tried to used
// This is working on backend but not on service portal
var total = parseFloat(newValue);
parent.g_form.setValue('montant',total);
//with this code I am able to get value outside of the multi row variable set
var spThis = this;
var catItem = spThis.angular.element(spThis.$('#sc_cat_item').find('sp-variable-layout')[0]).scope();
var parent_g_form = catItem.getGlideForm();
//this is working
alert(parent_g_form.getValue('caller'));
//this isn't working
parent_g_form.g_form.setValue('calculate',total);
So if anyone has been able to do it or have come across the same issue
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2021 06:06 AM
Hi,
refer this link for workaround
MRVS detect when a row is removed or deleted
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2021 05:17 AM
Hi,
you can form array of json object and set the mrvs variable value
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2021 05:37 AM
Hi sorry, I might no formulate it correctly.
I am trying to calculate the total price of several item pick up in multi row variable set so I have created this script
var multiRowVariableSet = JSON.parse(g_form.getValue('commande'));
//alert(gr.length);
//var myString = JSON.stringify(gr);
var total = 0;
for (var i = 0; i < multiRowVariableSet.length; i++) {
total = parseFloat(multiRowVariableSet[i].total_price) + parseFloat(total);
}
g_form.setValue('montant',total);
So this working, but I need something to trigger my script when someone add or remove an item in multi row variable set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2021 06:06 AM
Hi,
refer this link for workaround
MRVS detect when a row is removed or deleted
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2021 07:24 AM
I have been able to do it.
Thanks for your help
I have use the following script in my widget :
function($scope) {
$scope.$watch(function() {
return $scope.page.g_form.getValue('commande');
}, function(value) {
//alert(value);
var test = $scope.page.g_form.getValue('commande');
//alert(test);
$scope.page.g_form.setValue('calulate',test);
});
}