Advanced Properties
As well as the general properties, fields also have an 'advanced properties' tab. This deals with additional validation and permissions around the field. This is split into four main areas:
Visibility
This allows the field to be set to either hidden or visible by default, but then for that to change depending on whether one or more rules are met.
In the above example, the field is visible by default, but then hidden if the 'Amount' field is less that 100 (e.g. maybe an explanation isn't required for invoices below 100 in total).
Additional rules can be added by clicking the '+' icon. Groups can also be added here, meaning that more complex rules can be created and nested using 'And' and 'Or' conditions to indicate whether all conditions or just one condition in a group must be met.
Rules
This allows for additional validation rules to be put in place and a message displayed to the user if these rules are broken.
In this example the field can only contain a maximum of 30 characters.
Filters
In addition to rules some field types will also have filters. These work in a similar way but can be used to limit what data is displayed to a user. They are useful in 'dropdown' field types where you might be populating a dropdown control with a list of values for the user to select, but you want to limit what values are available.
Security
Here we can change the ability to see or enter data to a field depending on the stage of the process.
In the above example, the field is visible and editable, but that changes to 'read-only' if the process is at the stage of 'Managers Approval'. This would be a typical setting for a stage of the process where a user should be able to approve or reject a transaction but not change any of the values.
Regular Expression
While this parameter is actually displayed on the 'General Properties' tab, creation of regular expressions would be considered more of an 'advanced' option and so is included here. A regular expression is a commonly used method of doing advanced data validation and makes use of special characters that have a meaning when the expression is evaluated. This allows you to specify exactly the format of acceptable input in more detail that the 'Rules' option above.
E.g. if a field should contain a purchase order number in the format PO-123456 (where 123456 could be any legimate 6 digit number) then the following regular expression could be used:
^[pP][oO]-\d{6}$
The characters used are:
- ^ - Marks the start of the expression.
- [pP] - The first character must be a 'P' either upper or lower case.
- [oO] - The second character must be an 'O' again either upper or lower case.
- - The next character must be a dash.
- \d{6} - The next six characters must be digits.
- $ - This marks the end of the expression.
If you have not used regular expressions before then this may seem a little daunting, but there are many resources on the web that can help you understand the syntax. The website regex101.com is useful to help you test your expressions before use, change the 'flavour' to ECMAScript (JavaScript) for maximum compatibility as this is the validation used by UniFi.