Hi y’all, Carolina from the Support team here!
This week, I received a ticket about an issue with an Analysis script designed to calculate the difference between the last two variable values inserted into a device.
We advised pulling incoming data from the scope, comparing it with device data via variable IDs and timestamps, especially since a variable action is involved.
Do you know what scope is?
The “scope” refers to the data payload that is passed to an Analysis when it is triggered (usually by an Action, or dashboard widget like an Input Form). It contains the values and metadata that caused the trigger, so your analysis can process exactly those items rather than querying broadly.
For example: If an Analysis is triggered by a Variable Action, when the device triggers the action, the action then triggers the Analysis, and the variable’s value will arrive in the scope. The device is identified via the device ID. That way you won’t need to query the data that arrived at your device, saving you from using valuable API Resources and from possible timing bugs.
I hope this is helpful for other users as well ![]()
Cheers,