Agile Developer

Autogenerate fields

Axpert 11
TStructs (Forms)
IViews
Scripts
Axpert Jobs
Axpert Cards
HTML Plug-ins
Users & Roles
Workflow
Axpert API
Application Var/Params
Publish Axpert Apps
Axpert Mobile
Settings
Utilities
Customization
WebServices
Axfast

Autogenerate fields

Axpert will generate unique sequential numbers for autogenerated fields. An autogenerated number will have 2 parts. An alphabetical prefix followed by a unique sequential number. There can be more than one sequence for an autogenerated field. When there are multiple sequences defined, the sequence that has the Active field as True is considered for autogenerating the field value.

Each sequence is uniquely identified by the prefix. Use the Define Sequence property in the data section of autogenerate field properties to create one or more sequences.
Example:
Consider a loan application form that has an autogenerated field named ApplicationNo. The number generated in this field should be prefixed with ‘LAPP’ followed by a unique number starting from 1. To achieve this, create an autogenerate field with one sequence with a given prefix. In run time, as the user enters data in a form, for every record a unique sequential number will be generated and assigned as this field value. The number will be prefixed with ‘LAPP’.

Prefix fields

The prefix column can be set with a field name. The field name should be prefixed with a colon. This field is called the prefix field. Only fields in this tstruct can be used as prefix-field. The prefix field should be before the autogenerate field. At run time, the value in the prefix-field will be used as a prefix.
In the example above, consider a scenario where the prefix should be

  • ‘VAPP’ for Vehicle Loan Applications
  • ‘HAPP’ for Home Loan Applications
  • ‘LAPP” for Other Loan Applications

To achieve this, add a prefix field before the autogenerate field. The value in this field should be ‘VAPP’, ‘HAPP’, ‘LAPP’.
At run time, depending on the selection in the loan type field, the prefix will be set. But, the numbers generated will be sequential across all prefixes. To generate multiple sequences at run time, use dynamic sequences.

Dynamic Prefix

New sequences can be added at run time. That means, while creating the form, there may be only one sequence. But, using the value in prefix-field new sequences can be created at run time. Fields like Autogenerate are used to define static values For Example DOC001, DOC002. Instead of hard coding a set of predefined values we can use dynamic prefixes based on the field selection.

For Instance, real-time applications like ERP systems have predefined standards for transactions. Every transaction will begin with Company code, branch, financial year, transaction code (Sales order, Purchase Request, Stock Issue) respectively [CMP/BR/FY/ (SO/PR/SI….)/Running Sequence]. If the company does not have branches, then the transaction code will look like this [CMP/FY/Transaction Code/Sequence]

Create a form called Dynamic Prefix and create the fields. In the prefix field, calculate the entry. The values will be fetched from the Master table. The expression that is used in the prefix field will begin with {:} which represents Axpert dynamic prefix. After defining the prefix create an autogenerate field that will just select the prefix from the field rather than hard coding the entry prefix. Prefix definition Syntax example:
{:} + cmpcode + {\} + branch + {\} + finyear + {\} + transcode + {\}
After this visit the run site and find your form and execute to find the generated prefix.

Try Out

The employee form we have created has an employee code that is unique for an individual. If you have chosen the Whole number field type during the creation then it’s time to change it into an autogenerate field. Click on the particular field like empcode, Now click on the ellipsis (three dots) at the right bottom of the field, and select Change from the options shown. Successfully switch to Autogenerate field type and set appropriate prefix and length as desired. Repeat the same for the department code in the department master form.