'ServiceNow Paris - How to pass array from widget client script to server script after receiving broadcast

Our team is developing in ServiceNow (Paris) and 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 data.test 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!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source