Hi,
I've been creating an application for onboarding clients. For this I want to create an auto generated field in CDT. whenever a new client register for onboarding and successfully submits the form, automatically the unique onboarding number have to create for every client.
Is it possible to create?
Thanks in advance.
Discussion posts and replies are publicly visible
HI, You can create a field called "ID" in the CDT and while configuring you can check mark for Auto generation option.
So to be clear: you want to auto-generate a unique Reference Number for each onboarding process instance? The way I've done this in the past is to have a database table that stores a sequence number, and a stored procedure that increments and then returns the sequence number. The actual reference number might be constructed from, say, a date and the sequence number itself e.g. 20220300005 - that is, the year 2022, the month of March (03) and sequence number 00005. Your stored proc would also determine if the currently stored sequence number is for a different month and, if so, reset the sequence to 1.
Using a table allows you re-use it for other sequence numbers for other contexts i.e. it could be a shared service across multiple applications.
Thank you for your valuable reply :)
I use this function when generating a unique identifier.
a!localVariables( local!raw: a!refreshVariable( value: concat( dec2hex(toint(rand(4)*256),2), "-", dec2hex(toint(rand(2)*256),2), "-", dec2hex(toint(rand(2)*256),2), "-", dec2hex(toint(rand(2)*256),2), "-", dec2hex(datetext(now(),"yyyy"),3), dec2hex(datetext(now(),"MMdd"),3), dec2hex(datetext(now(),"HHmm"),3), dec2hex(datetext(now(),"SSss"),3) ), refreshAlways: true ), local!rawLength: len(local!raw), concat( a!forEach( items: 1 + enumerate(local!rawLength), expression: a!localVariables( local!currentCharacter: index( local!raw, fv!item, {} ), if( a!isNullOrEmpty( stripwith( lower(local!currentCharacter), "abcdefghijklmnopqkstuvwxyz" ) ), if( rand(1) < 0.5, lower(local!currentCharacter), local!currentCharacter ), local!currentCharacter ) ) ) ) )
Thank you for your valuable reply
Hi in order to autogenerate the value in any column (in normal use case it is the primary key of the CDT "id") use @GeneratedValue annotation in the xsd
in the database table mark the value as autoincrement.
This will create a new autoincrement value each time a transaction is made.
It should look something lie this
<xsd:element name="appianColumnName" nillable="true" type="xsd:int"> <xsd:annotation> <xsd:appinfo source="appian.jpa">@Id @GeneratedValue @Column(name="databaseColumnName", nullable=false, unique=true, columnDefinition="INT")</xsd:appinfo> </xsd:annotation> </xsd:element>
Thank you for your valuable reply... It works well