Establish Communication between two widgets in ServiceNow – Service Portal

Use Case:

Let us say for example we created a widget to just upload a file and other widget to display the files for the current record. As and when the file is uploaded in the first widget, we need to refresh the attachment list in second widget

This can be done by sending a broadcast message from the client controller in first widget and capturing that signal in the second widget

First Widget


Second Widget

$rootScope.$on(‘file-attached’, function(event,data) {
console.log(‘YYYYYYYYYYYYY  event recevied’);

$scope.refreshAttachments =function() {
$scope.attachmentHandler.setParams(“u_custom_table”, $, 1024 * 1024 *         $;