How to pass array from widget client script to server script after receiving broadcast
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2022 02:58 PM
Our team has a widget that broadcasts a number of data points and arrays stored in an object:
var obj = {
catSelected: c.selected.cat_active,
catName: c.selected.hro_category_name,
catAppArr: c.selected.hro_category_apps,
catDesc: c.selected.hro_category_desc,
catSysID: c.selected.hro_category_sysID
}
$rootScope.$broadcast('changeCategories', obj);
On the other widget, we receive the broadcast:
$rootScope.$on('changeCategories', function(event, data) {
c.server.get({
action: 'retrieve_data'
}).then(function() {
c.data.appArr = data.catAppArr;
});
})
and would like to send it over to the server side, how do we do this? So far we have something like the below, but does not show up in the console:
if (input && input.action == 'retrieve_data') {
data.test = input.appArr;
}
Do we even need c.server.get to pass that array over to the server? Thanks for your help!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2022 03:25 PM
You need to pass the appArr within the input object:
$rootScope.$on('changeCategories', function(event, data) {
c.server.get({
action: 'retrieve_data',
appArr: ['someItem', 'anotherItem']
}).then(function() {
c.data.appArr = data.catAppArr;
});
})
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2022 06:11 AM
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2022 06:22 AM
Where are you logging it to the console? Can you try it here?
$rootScope.$on('changeCategories', function(event, data) {
c.server.get({
action: 'retrieve_data',
appArr: ['someItem', 'anotherItem']
}).then(function() {
console.log("data.test: " + data.test)
c.data.appArr = data.catAppArr;
});
})
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2022 06:59 AM
it shows "data.test: undefined". Is the below server script portion correct?
if (input && input.action == 'retrieve_data') {
data.test = input.appArr;
}