Hi everyone, I’ve recently been having issues with ticket numbering in a sales system I built in Adalo.
The logic is always “maximum ticket# + 1.” It had been working fine until a few days ago; I’m not sure if it’s because the numbering is already around 8,000 tickets.
***In a text field, I use a formula that calculates “maximum ticket + 1,” and then I use that field to update the ticket number for that purchase in the database.
I tried creating a collection to store the last ticket number to avoid the delay in finding the maximum, so I could just query that data in the database. But for some strange reason, it doesn’t update. The relationship is already established, and the action is set up to retrieve the ticket number (which is the last ticket or the maximum) when creating the sale, but it still doesn’t update.
What do you guys use to number tickets? As I said, in my case it had worked perfectly for two years, but now I don’t know why it’s failing all the tickets just get blank or #1.
Thanks in advance.
That’s a massive query, even though it seems simple on the surface.
When you say you created a collection to store the last ticket number, there should only be one record in that collection that stores the current ticket number. Then each new ticket simply increments that number by 1.
For example:
Tickets Collection
- Ticket #8001
- Ticket #8002
- Ticket #8003
- etc.
Maximum Ticket Collection
When a new ticket is created:
- Read the Current Number from the Maximum Ticket record.
- Assign that number + 1 to the new ticket.
- Update the Maximum Ticket record to the new value.
I would avoid running a “max ticket + 1” calculation across thousands of records every time a ticket is created. With 8,000+ tickets, that’s a much heavier query than simply incrementing a single number.
One thing to watch out for is multiple users creating tickets at the exact same time, which can still create duplicate or skipped numbers depending on how the actions are configured.
If you’d like, you can book a one-on-one mentoring session with me and we can walk through your database structure and actions together. It should only take a few minutes to identify where the numbering is breaking.
Thanks @Flawless yes it use one record +1 and no multi-users in this case.
but the problem is that the “only” record doesn’t update when the new ticket it’s created, the action for the update is already set but something goes wrong. (the new ticket number its stored in a input field that retrieve the only record+1 in a custom formula.
Thanks in advance.
True. The challenge with Adalo is that updating a separate record isn’t always straightforward because the app needs a way to actually query to pull the record first before it can update it.
I’ve handled similar situations using a countdown timer list trick that loads the record first and then updates it. Another option is using Make or Zapier to manage the incrementing outside of Adalo.
I will try with a modal after create the ticket (something like “payment ok” message) to update the record with a countdown that update the record then goes to print screen.
Thanks @Flawless
@Fercho just in case - is there anything which stops you from using ID as the ticket number? IDs are (1) autoincrementing and (b) unique.
You can also use ID as a part of human-readable ticket ID field (e.g. TICKET-2026-4551, where 4551 is the built-in ID).
Best,
Victor.
P.S. Using autoincrementing logic creates some security issues, but you’re using the same logic anyway.
Thanks @Victor i tried Record ID to numbering some months ago, but i faced the problem that i need to show the number that the system will assign to the ticket before ticket creation:
Something like:
The number of this ticket will be: #1450 *(before the ticket will create)
*This is for internal ticket Authorization Policies
But I don’t know if searching for an ID is just as “hard” as searching for a user-defined field in the database in my case the field “ticket number”. (i think “ID maximun” can´t be query)
I create a collection to store the ID of last ticket but something goes wrong and this filed never be update. (the relationship and the actions logic are set but doesn’t work) i will try @Flawless trick solution.
Do you know some other way to update that kind of record?
Thanks in advance
Hi @Fercho,
Ok, thanks for clarification. Getting the last record ID to show projected next one will be cumbersome, if you keep your existing logic it won’t help.
In my personal opinion, showing the future identification number is not a very good idea as it creates potential issues. Maybe you could consider creating the record before actual payment, mark it as draft, and work with it later on and remove “draft” when ticket is purchased. You can discard draft records later on. Of course this will require app modifications. But with this you can be sure that the ticket is unique.
If you’d like to keep existing logic, you can try a workaround of getting the max existing record by creating a single-item list of tickets, sorted by ticketId → descending, and limit nb of items to one. This will give you one record with the max number, and you can use it later on.
But I’d try modifying the DB structure to make sales more robust.
Best,
Victor.