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-03-2022 07:08 AM
Sorry, I had to go and look at an example of how I've used this in the past.
Can you try using the data object in the response (r)
$rootScope.$on('changeCategories', function(event, data) {
c.server.get({
action: 'retrieve_data',
appArr: ['someItem', 'anotherItem']
}).then(function(r) {
console.log("r.data.test: " + r.data.test)
c.data.appArr = r.data.catAppArr;
});
})
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2022 07:24 AM
I really appreciate you taking the time to troubleshoot this with me! I've changed client as such:
$rootScope.$on('changeCategories', function(event, data) {
c.server.get({
action: 'retrieve_data',
appArr: data.catAppArr
}).then(function(r) {
console.log("r.data.test: " + r.data.test)
c.data.appArr = r.data.catAppArr;
});
})
In the console I see this:
and

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2022 07:33 AM
What are you trying to do next?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2022 07:39 AM
We would like to use some of the data points in that array to do a GlideRecord query.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2022 07:45 AM
In that case, you can loop through each object in your array (r.data.test) and build your GlideRecord queries.