- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2025 09:39 PM
I would like to read field values from a portal form widget and pass them to another widget.
I would also like to receive values from other widgets and set them in fields.
Is this possible?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2025 02:13 AM - edited 09-02-2025 02:13 AM
Hi @bonsai ,
Yes Possible...Use $broadcast, $emit, and $on - most widely used pattern
In the source widget (sender):
// In the client controller
$rootScope.$broadcast('myEventName', valueToShare);
In the target widget (receiver):
// In the client controller
$scope.$on('myEventName', function(event, receivedValue) {
$scope.myReceivedValue = receivedValue;
});
This lets you send a value from one widget (e.g. a form input) and have another widget capture and use it...
Alternate approach: If you need to pass data that the server script of another widget uses..
In Widget A, push parameters into the URL using $location:
api.controller = function($location, $timeout) {
$timeout(function () {
$location.url("/sp?id=somePage&sharedValue=" + encodeURIComponent(value));
}, 100);
};
In Widget B server side script, capture it:
(function() {
data.value = $sp.getParameter('sharedValue');
})();
Detailed article here: https://www.servicenow.com/community/developer-forum/service-portal-need-to-pass-the-value-from-one-...
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2025 10:00 PM
what's your actual business requirement here?
You can always communicate between 2 widgets by passing info
If my response helped please mark it correct and close the thread so that it benefits future readers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2025 12:01 AM
Hi @bonsai ,
Yes it is possible to share field values between Service Portal widgets, including reading values from a form widget and passing them to another widget.
For inter-widget communication:
Widgets can broadcast and listen for events via $rootScope.
- You can use $broadcast method of information to be communicated/shared.
- In Second widget receiving the values using $on method.
This post explained in detail.
Get a variable Value and present it to another page in another widget.
Article:
How to comunicate between widgets - Service Portal
Thanks,
Bhimashankar H
-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2025 02:13 AM - edited 09-02-2025 02:13 AM
Hi @bonsai ,
Yes Possible...Use $broadcast, $emit, and $on - most widely used pattern
In the source widget (sender):
// In the client controller
$rootScope.$broadcast('myEventName', valueToShare);
In the target widget (receiver):
// In the client controller
$scope.$on('myEventName', function(event, receivedValue) {
$scope.myReceivedValue = receivedValue;
});
This lets you send a value from one widget (e.g. a form input) and have another widget capture and use it...
Alternate approach: If you need to pass data that the server script of another widget uses..
In Widget A, push parameters into the URL using $location:
api.controller = function($location, $timeout) {
$timeout(function () {
$location.url("/sp?id=somePage&sharedValue=" + encodeURIComponent(value));
}, 100);
};
In Widget B server side script, capture it:
(function() {
data.value = $sp.getParameter('sharedValue');
})();
Detailed article here: https://www.servicenow.com/community/developer-forum/service-portal-need-to-pass-the-value-from-one-...
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2025 08:13 PM
Hi @bonsai ,
I hope you saw my reply.
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. It will help future readers as well having similar kind of questions and close the thread.
Thanks,
Bhimashankar H