Hi
I started working from the last month as Appian developer
Need help or suggestion
Tying to implement custom autogenerated primary key in sequence.
Example - INVREQ0001 , INVREQ0002 and so on.
If someone knows how to generate this then please let me know
Many Thanks in advance
Discussion posts and replies are publicly visible
Hi there,
I don't think that is possible. Tho you can do it with plain numbers, with a jump too e.g. 10,20,30...n (after 22.3) but mashing it up with some custom characters will be not straightforward. So you will have to check for the last data in the table, add one to it and then concat your characters.
Does this need to be stored in the database or can it be just showed to the user this way?
its read-only field
I only want to create this on the database side.
As Stefan suggests, I would let the DB auto-increment an integer primary key, then format it this way to display for the user. You can even save the formatted text back to the DB based on the primary key if you want.
a!localVariables( local!id: 2, concat( "INVREQ", repeat(4-len(local!id),"0"), local!id ) )
Or, with similar logic, store the ID value (integer) in a constant within the application, at the start of each request, use the Increment Constant smart service to increment it and pull the new value to format into the ID value with "INVREQ__".
Hi Chris
Thanks for the reply.
Actually, I found one example and tried to do the same in the below way.
create function CustomerNumber (@id int) returns char(5) as begin return 'C' + right('0000' + convert(varchar(10), @id), 4) endBut the above function is not working in the appian clould database.