- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 08:21 AM
Hi all, it seems that this is impossible to achieve.
I need to run a UI Script (in the Service Portal) when something changes to a MRVS (Multi Row Variable Set), but it seems that MRVS are not shown in the dropdown menu where I select the Variable (screenshot below).
NB: I don't need to set "Applies to" to a Variable Set, I need to apply the script to the Catalog Item.
Because when the content of the MRVS changes, I need to take the full content of it via script and use to change the value of another variable of the content item, which is not part of that MRVS.
Is this possible at all?
If not, any workarounds?
Thanks!
Mauro
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 12:47 PM
Hi Mauro,
Here's one way to do this.
1) create 2 Catalog Item variables.
1a) A simple multi-line text variable. This can be hidden with a UI Policy or Client Script, and may not be needed - see below.
1b) Type=Custom, Type Specifications, Widget = <Click the New button to create a new Widget>.
Paste this text into the Client controller field, and update where commented:
api.controller=function($scope) {
/* widget controller */
var c = this;
var mrvsName = 'mrvs_internal_name'; // replace with your MRVS internal name
$scope.$watch(function() {
return $scope.page.g_form.getValue(mrvsName);
}, function(value) {
g_form = $scope.page.g_form;
g_form.setValue('multi_line_text_variable_name', value); //replace with your text variable name
});
};
2) Trigger your onChange Catalog Client Script when the variable in 1A changes. An alternative, though it's hiding the code a bit so will drive someone nuts later is to just do whatever you were going to do in that script in the widget script instead of setting the value of a holding variable.
So in summary, in Service Portal whenever a row is Added, Deleted, or Edited, the custom variable widget will update the multi-line text variable (or whatever) since it is "watching" for a change.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 12:47 PM
Hi Mauro,
Here's one way to do this.
1) create 2 Catalog Item variables.
1a) A simple multi-line text variable. This can be hidden with a UI Policy or Client Script, and may not be needed - see below.
1b) Type=Custom, Type Specifications, Widget = <Click the New button to create a new Widget>.
Paste this text into the Client controller field, and update where commented:
api.controller=function($scope) {
/* widget controller */
var c = this;
var mrvsName = 'mrvs_internal_name'; // replace with your MRVS internal name
$scope.$watch(function() {
return $scope.page.g_form.getValue(mrvsName);
}, function(value) {
g_form = $scope.page.g_form;
g_form.setValue('multi_line_text_variable_name', value); //replace with your text variable name
});
};
2) Trigger your onChange Catalog Client Script when the variable in 1A changes. An alternative, though it's hiding the code a bit so will drive someone nuts later is to just do whatever you were going to do in that script in the widget script instead of setting the value of a holding variable.
So in summary, in Service Portal whenever a row is Added, Deleted, or Edited, the custom variable widget will update the multi-line text variable (or whatever) since it is "watching" for a change.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 10:43 PM
Hi Brad, thanks a lot for your help. This is indeed a great answer and a confirmation that MRVS are excluded from the OOB onChange Client Scripts. I will make this widget and test it, thanks again, much appreciated.
Mauro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2023 06:36 AM
This is so useful, thanks for taking the time to post it here!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 02:06 AM
Thanks a Brad for the information. Any way we can find out that the change was due to addition of a row or the row was edited ???