Get All variable values onChange to a widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2023 11:55 PM
I have a catalog item with 1 custom variable(Service portal widget mapped) and 5 normal variables like single line text.
In the custom variable, I want to show all the remaining filled variable values and whenever any variable value changes, it should auto update in that widget.
For example: My single line text variables hold 'Abc', 'def', 'ghi', 'jkl', 'mno' values in them then my widget should display
Abc, def, ghi, jkl, mno.
If I update ghi to xyz then immediately, widget should show Abc, def, xyz, jkl, mno.\
How can i do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2023 12:17 AM
what's the business requirement for this?
check this link
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2023 04:02 AM
Hi Ankur,
Business requirement : We have a custom widget variable at top of the catalog item which shows the summary of all the filled variables on the form.
So whenever a variable is filled, it should get added to summary widget and similarly whenever a value changes it should update in summary widget.
All HTML and CSS stuff for summary widget i have defined already and to show variables, i used ng-repeat.
Now only thing is how do i pass data to that ng-repeat.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2023 04:08 AM
did you check the link I shared above?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2023 10:19 AM
I was able to get that using below script in client controller
function($scope) {
var c = this;
$scope.$watch(function () {
return $scope.page.g_form.getValue('name_of_variable');
}, function (value) {
c.data.message = value;
});
}
This script will instantly set the updated value of variable to c.data.message which I can access in html.
This works fine for one variable but I want to make it work for multiple variables. How can I do that? I have the variable names in an array.