i want to auto generate id in the format IDA201912000001

i want to auto generate id in the format IDA(year)(month)(number) eg. IDA202001000009

and i want the last 6 digits to increase themselves whenever i create new record

kindly help me ASAP

Hi Hanishq,

Did you check the system actions, I believe something like this could work for your scenario
You need to have a kind of counter and then increment it anytime a new record is created.

Example: 

"IDA" +FormatDateTime(CurrDate(),"yyyyMM")+ FormatText(Counter,6,6,True,"0")
Solution

Hi Hanishq,

Like Paulo said, you can build your "id" as the example above. For the counter you can, for example, count the number of records you have in DB and increment one more (if you are not deleting anything from DB). In otherway you can append the Primary Key (Id) of the table since it will be always unique and incremental (but you need to take care if you need to reset this number in the future). In other way, and probably the best, is to store this number in a table of "counters" and increment that number. Like this you can always reset it when you want.

Regards,

Solution

Tiago Gomes wrote:

Hi Hanishq,

Like Paulo said, you can build your "id" as the example above. For the counter you can, for example, count the number of records you have in DB and increment one more (if you are not deleting anything from DB). In otherway you can append the Primary Key (Id) of the table since it will be always unique and incremental (but you need to take care if you need to reset this number in the future). In other way, and probably the best, is to store this number in a table of "counters" and increment that number. Like this you can always reset it when you want.

Regards,

Further to Tiago's suggestion you can also add the counter ass a site property which will again allow you to increment and reset.

I wouldn't suggest to store that value in a site property and change it in run time because:

1. Assigning a Site Property frequently causes very poor performance because of the cache invalidation.

2. It is STILL going to write to the database (site properties are stored in the database). So even if writing to Site Properties did not invalidate the cache and cause big performance slowdowns, this is still not saving any time.

Regards

Hi Sam,

While a site property would work, they are not intended to be changed often.  It would not be considered best practice to use a site property for this.

https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Data/Handling_Data/Site_Property

Hope this helps.

Kind regards,

Stuart.

Hi,

I needed to do that some time ago and created a little action.

View the attachment and take ideas.

You can also test it on the screen.

Hope it helps