Increment table ID field from the app

Hi. I am trying to increment the table ID number which is a text field via an app. I managed to get this to work when the app is running. My current trigger looks following:

My table looks like this:
image

I am looking for a way to load the last table entry to the variable in the app as a string → convert the string to integer → increment the integer → convert it back to string → and store it into the same table on the next ID field.

My current triggers work when I start with an empty table and it works until I restart the app.

you can use connector to achieve your goal.

1 Like

hello @Andres, great question!!

as @mcc6025 correctly pointed out, you could use a Connector to the Table API. here’s a quick guide:

  1. create a Connector Function to the Table. for reference, here’s the endpoint I used: /records?limit=1&sortBy=_sequenceNumber&sortDir=desc. as you can see it will always output the largest ID in the Table:


  2. you can then Run the Connector Function from your app and simply increment the max value by 1:

  3. result:

at this point, you can create a new Table Record with that ID (7 in this example).

does that make sense?? let us know!!

I added an extra field to the table to save the incremented integer to the first record when done adding a new record. Then added a “load record” trigger to pull the last ID saved to the table when the first step is opened and save it to the integer. That way you can restart the app as many times as needed and it will still pull the last saved ID from the table. I haven’t had the time to add the table API and test but I know the above way works just fine. I’m kind of late to the party here but let me know if I can help out!

1 Like

when I developed my first tulip app, I once used this way you mentioned
yes, the way works well.

Thanks, I got it solved with Table API.

Hello All,

I think this topic is great to continue working on and I want to summarize here for future reference what is possible now with Queries and Aggregations (without connectors)
For example if someone wants an id such as : Text-{year 2 digits}-{sequential number per year}, I will share a way to do so :

  1. Prepare your table and add a year field for easy queries :
    image

  2. Create query per year :

  3. Create aggregation (count) :

  4. Load query and aggregation in your app (+ create a record placeholder it will be useful) :
    image

  5. Format the current date as needed when app is started using Format_Date_TZ :

  6. You have everything for your id (if you want to start from 1 and not 0 you will need one more data manipulation to increment the value from table aggregation) :

Results :

1 Like

This will create equal Id (based on filtered count value) if record - not last - is deleted.

1 Like

you are right. but I still thanks to pte for his sharing.
in my opinion, hope tulip provides the cursor operation, such as movetolast, then we can load the last record, and get the ID of last record, generate the unique new ID by expression.

1 Like

Hi guys,


Knowing that i have to apply some filters before extracting the ID, I want to know what i have to add to “/api/v3/tables/iM8DsQk8ZAAD68BJM/records?limit=1&sortBy=mrvac_dateplanifie&sortDir=asc” to be able to use as many filters as i want.
thank you,

hello @FahdERM, I had included a brief descirption of how to do this here: Using Query Parameters in Connectors Functions - #2 by gio.

but in brief, you can add: filters.x.field, filters.x.arg, filters.x.functionType on as many filters as you’d like. I would recommend adding them as Query Parameters in the function as such:

is this what you’re looking for?? let us know!!

@gio exactly :


thank you for your help.

1 Like

great to hear, let us know if anything else comes up!!

1 Like

Hi @gio,
Hope you are doing Well. In fact i tried to get the ID of this record and use it on the app and i had done it but the issue is that the ID i had recover had the form [“1235”] for example :

and i can’t use it to load the table record because the table record ID has a text form 1235. A solution that i had adopted is to use nested objects :


Is there a solution to convert the first ID and use it instead of the second because i had recently encountred some problems using nested objects?
thank you,

hello @FahdERM!! doing well, hope you are too.

if you add a . before the id on the Extractor it will convert it to a string for you:

can you confirm this works as intended for you??

@gio, Thank you for this example. Yes, it worked for me but i had to add . before and .0 after otherwise it won’t work.
thank you,

1 Like