Load tulip table last record

Hello,
I have a regular Tulip Table, I want to load the last record to the app, I don’t know what is the last ID, how can I do that ?
Similar to the sql statement : select top 1 * from table_name

Thank you,
Amit

hello @Amit, there are two ways to achieve this:

  1. create a Table Query, add a Sort (for example on Due Date) and Limit the # of Records to 1. to do this you will need to link the Query to an Interactive Table and have a field to sort by.
  2. use the /tables/{tableId}/records endpoint on the Table API. you can then add a sortBy parameter to sort by _sequenceNumber

would either of these options work for what you’re trying to build?? let us know

Hi Gio,
I’m trying to create a trigger in the “on step enter” so posibility 1 is not executable.
About the second option, I’m not so familiar with the API, havn’t done one by myself yet, I hope I will succeed with that.

Thank you for your help
Amit

Amit, what is the record you are trying to load? What is the story behind it, is there another way to identify the last record?

Hi Gilad,
Although Anja already helped me with this issue by create an API connector function to get this record I will explain the need and solution :
The need is to get the last value of machine activity field contains number of produced packages, save it in a variable, than catch the next input, decrease it by the value save aside, than you get the quantity of packs produced in the last X minutes - save this result in a Tulip table, afterward using this data for analytics.
The solution is create an API connector function in front of a table, limited to 1 record and sort be the _SequenceNumber descending, set which field or fields should be output and what left is call the function from the app

Thank you for the idea and help,
Amit

| giladl Tulip Team
May 19 |

  • | - |

Amit, what is the record you are trying to load? What is the story behind it, is there another way to identify the last record?

Here is an idea. It looks like you already have a table for all the Machines?

Create a column in that table called “Last Logged Activity ID” (for example) then store the ID of the record that was just updated with the produced packages number. Then when the next machine event arrives you reload the record based on the ID stored in the Machine table and read the value. Notice that if you do it this way your record may already be loaded, so reloading should conditional, meaning only if the app was restarted.

Something like this:

  • When event happens
    • If Last Produced Packages is blank

    • Load Current Machine Activity by id Current Machine.Last Logged Activity ID

    • Produced Packages = Current Machine Activity.Produced Packages

    • New Product Packages = Produced Packages - event data.produced packages

Let me know if that helps?

  • Gilad