Scope.find variable

Scope.find variable

@JORDI masmitja

Hi community,

We have an action, which triggers an analytics task.

this search works fine,

  const { location } = scope.find(x => x.variable === 'location');
  context.log('location lat:' + location.coordinates[1]);

but not, for example, the next one …

const { battery } = scope.find(x => x.variable === 'batv');
context.log('battery json ' + JSON.stringify(battery));

This is the output scope on analytics …

{“id”:“5f7f649008c9ff00278ccb37”,“created_at”:“2020-10-08T19:12:16.947Z”,“time”:“2020-10-08T19:12:16.947Z”,“bucket”:“5f7f3932aaf8b000278703a2”,“variable”:“alarm_status”,“origin”:“5f7f3932aaf8b000278703a1”,“serie”:“1602184336921”,“value”:false},
{“id”:“5f7f649008c9ff00278ccb38”,“created_at”:“2020-10-08T19:12:16.947Z”,“time”:“2020-10-08T19:12:16.947Z”,“bucket”:“5f7f3932aaf8b000278703a2”,“variable”:“batv”,“origin”:“5f7f3932aaf8b000278703a1”,“serie”:“1602184336921”,“value”:3.993},
{“id”:“5f7f649008c9ff00278ccb3e”,“created_at”:“2020-10-08T19:12:16.947Z”,“time”:“2020-10-08T19:12:16.947Z”,“bucket”:“5f7f3932aaf8b000278703a2”,“variable”:“location”,“origin”:“5f7f3932aaf8b000278703a1”,“serie”:“1602184336921”,“location”:{“type”:“Point”,“coordinates”:[2.494605,42.179084]},“value”:“42.179084,2.494605”}]

Best Regards,
Jordi.