How to autoincrement a number in mendix?

0
I want to autoincrement the field which is a ticket_no. I want this to be autopopulated in the field and incresead by one everytime. I don’t want to make this attribute as a autonumber because if i click cancel button then also it increments I dont want this. My attribute ticket_no is a string. I want it to be displayed as 1, 2, 3…. etc. How can I achieve this?
asked
2 answers
0

Hi Saiba,

 

Using a Before Commit Event, you check whether the ticket number is populated. If not, you can do a retrieve all (from database) and count. You can then populate your ticket value with the count + 1.

 

Note that there may be an instance where these transactions are concurrent, which may result in a duplicate ticket number. The best is actually the autonumber attribute for this reason.

answered
0

Hi Saiba,

 

You could try to create a Entity called TicketNumber with a AutoNumber Attribute.

Make a 1*1 Assocation to your current Ticket Entity and create the TicketNumber after the successfull Commit of the Ticket.

 

Hope this helps,

 

 

answered