I have a Tulip Table that contains metadata about the whole productive process. I have sorted the data in descending order using a table query.
I have integrated this table into a Tulip App, I have created a placeholder and called the query that I created previously in the table editor.
I want to load the last record of the table to the placeholder using App triggers. As the table was sorted in descending order, I would like to load the last row of the table to the placeholder when the App is being opened.
However, if you don’t know the exact ID of the record you want to load, this trigger is going to fail. Therefore, I would like to know if there is any solution or workaround for this issue. So I can retrieve the row and load it to the placeholder using another method.
Moreover, just passing the ID I don’t know the ID of row that must be loaded because this is a trigger that will be called every time the App initiates. The ID is supposed to be completely different because they are created using a randomstring() function. I also thought about using numbers and increasing them one by one after each run but the problem remains the same. How could I retrieve the first row (the one that was created last).
I need to load the placeholder because those placeholders belong to 2 different apps. For that reason I need to load it, but I don’t know where from.
If I’m understanding correctly, couldn’t you use a query to get the most recently created record and then an aggregation to get its ID, and use that aggregation for the ID where you need it?
Exactly, currently I can sort the table data using a query but I cannot load the last created record into the placeholder. I thought it was possible using queries but I have not figured it out. I was trying it using trigger logic. Perhaps there is another way of doing this. In any case, I stay tuned.
Thank you for your response.
I think the secret sauce you’re missing here is you need to format your query to output one result.
Then aggregate on the MODE of the ID column.
You will return one value which is the ID you’re looking to return.
Hello, thank you for your reply.
I already formatted a query to output one result. I had not thought about the Mode aggregation. Nevertheless, I still don’t see how that unique value can be loaded into a placeholder using trigger logic.
When I am setting up a trigger I select: table records > load record > by ID: (enter ID string) > into: (select placeholder).
My problem is that in order to load this record to a placeholder, I must know the id of that specific record, or have it stored in a variable or another know record, which is impossible since that trigger is being called just at the start of the App.
On the other hand, there is no automatic way of loading the query output (last record with x condition) without using trigger logic. Or at least I have not discovered it yet.
I need the record in that placeholder. I hope this clarifies the issue.
Orlando -
So if i’m following you your query would just be sort - Date Updated - Newest to Oldest
Limit 1 record
Aggregate the MODE of the ID Column
Then in App you would format your query something like below so you’re selecting the aggregation.
Because this outputs only one result as MODE you can then use that one ID you loaded as the reference ID for loading your record into the placeholder.
The screenshot above is from a trigger on app start, so it is possible to load the most recent updated row from a specific table when an app loads, automatically to your point.
Depending on the ID you need loaded you’ll need to define more filters into your table query to get the exact result you need.
But bottom line is, you must use MODE on the ID column of the table in your aggregation. From there you can simply use that aggregation to load the specific record.
Hope this helps explain it a bit better.
-Erik
1 Like