Data Table Query to Return a Device ID to a Gateway

workflow
#1

I am struggling with understanding querying a data table (populated by our manufacturing team) with gateway serial numbers that have been sold. The gateway (once powered and has some form of internet connection will send a POST request with its {’'serial": “ABC123XYZ”}. Once this is done we will query the data table for this serial number. If the serial number is found we want to return the deviceID assigned to that gateway in the response to the POST request. If it is not found in that list we want to return an error.

The following image is what I have done in an attempt to query the data table… is there any advice on how to accomplish the feat of comparing the serial number posted and the serial numbers in the data table to see if that device belongs?

Best Regards,
Leo Bach

#2

Hello @Leo_Bach1!

Querying a data table can be accomplished by two of our workflow nodes. The first is the Table: Get Rows Node that you have implemented, and the second the Losant API Node. The way you have implemented the Table: Get Rows node would work by locating that serial number and returning the number of times it is seen, the time created, etc. If that particular serial number is not found, it will return a 0, and you can create a conditional (such as if totalCount=0 return error) to error when no matching number is found. Should your needs change in the future, the Query Mode allows for advanced templating as well. The Losant API Node has a “Data Table Rows: Query” action that can also allow for more templating and advanced searches, as well as the above detailed functionalities. Either node will be able to accomplish comparing the serial numbers.

For the same query, the Table: Get Rows node payload looks like this:
45%20AM

And the Losant API node payload looks like this:

Hopefully this helps!
Julia

#3

Julia,
Thanks for the quick response. You’ve cleared it up.
As always, spectacular customer support.
Thanks!
-Leo

1 Like