UI field formatters can be defined that enforce a format according to a regular expression.
The UI field formatters are defined in an app resource at the discipline level. Access the app resources as an admin user by clicking on your user name and selecting Resources then App Resources.
Use the panel on the left of the App Resources page to navigate to the appropriate discipline and click on the Add Resource button. In the dialog asking for a Resource Type, click on App Resource and then on Field Formatters.
Add a new format element to the formats list. This can be done by copying an existing format such as the one above with the name “CatalogNumber”, deleting the autonumber and field elements, and changing the name attribute to a new value such as “CatalogNumberRegex”.
Next add a single field element to the new format with three attributes, type, value, and pattern. The type attribute should be “regex”. The value attribute should be the regular expression to be enforced. The pattern attribute will be used as the mouse-over hint for the field. Finally save the UIFormatters app resource using the button on the bottom right.
This makes the regex formatter available. It must then be assigned to the field in the schema configuration using the name that was given to the new formatter, which is most easily accomplished through Specify 6. After that, the Specify 7 server and any Specify 6 clients should be restarted.
To set the format in the schema configuration:
-
Log into Specify as an admin user.
-
Go to Select → Schema Configuration.
-
Select your language from the Available Locales and click Edit a Schema.
-
In the list of tables, scroll down to collectionobject and click it to select.
-
In the list of fields that appears, select catalogNumber.
-
Expand the drop down list next to the Field Format line to see the different Catalog Number format options.
-
The new format you created in the UI Formatters file should be there. Select it.
-
Click OK.
-
Restart Specify.
-
In the Schema Configuration window, make sure your new UI Formatter is still being correctly assigned to the Collection Object’s Catalog Number field.