Important: Please read the guide To Change a Catalog Number Format (other than default) before following this if you plan to change the
catalogNumber
in your collection.
A regular expression format allows the user to create a format that contains sections that are not always required, but the value is otherwise formatted. The basic steps are to export your UI Formatter, edit it, reimport it and assign the format through the schema config.
-
Export your UI Formatter
-
Add the Other Resources tab
-
Select Help → About.
- Double click your Database name to open the hidden Local Preferences window.
- In the Local Prefs window, click Add Property at the bottom of the window.
- Fill in the Property value for the newly added line with ADD_IMP_RES. Capitalization matters, so make sure all the letters are capitalized.
- In the Value field, enter true, then click somewhere else on the screen to set the value.
-
Restart Specify
-
Log into Specify as an admin user.
-
Select System → Resource Import/Export.
- The next window is notifying you that any unsaved work may be lost if you continue. If you have any work you want to save, select Cancel. If you are ready to continue, select Continue.
- The next window asks you to select a user’s resources to edit. Select My Resources.
- In the Resource Import/Export window, select Discipline from the drop down list and click the Other Resources tab.
- Scroll down to the bottom of the list and select UIFormatters then click Export.
-
Select a location to export it and click Save.
-
Leave this screen open if you can, because you will return to it immediately after editing.
-
Edit your UI Formatter file.
-
Open the UI Formatter file using a text editor such as Notepad++.
-
Add this to the code below the section with the phrase
name=”CatalogNumber”
<format system="false" name="W" class="edu.ku.brc.specify.datamodel.CollectionObject" fieldname="catalogNumber" default="false">
<field type="regex" size="X" minsize="Y" value="value" pattern="Z"/>
</format>
-
Replace the W with the name you want to use. You can use any name, but the simpler (no spaces or special characters) the better.
-
Replace the X with the maximum length the catalog number will be including separators such as spaces. So, for example if your catalog number could be as long as “EX 1234-5678 A”, you would enter 14.
-
Replace the Y with the minimum value your catalog number might be including separators. So for example if your catalog number might be as short as “EX 1234-56”, you would enter 10.
-
Replace the value with the value you would like to use for the format. There are guides for regular expression available online. Here are a few you can use: https://cheatography.com/davechild/cheat-sheets/regular-expressions/ or Regular expression syntax cheat sheet - JavaScript | MDN. If neither are clear, you can let us know the format you want to use and we can tell you what to put in that section.
-
Replace the Z with the pattern you want to appear in hints for the users. So in the examples above, you would enter “EX ####-#### A”.
-
Once you have the format the way you want it, click save.
-
Reimport the UI Formatters file.
-
Reopen the Resource Import/Export dialog and select Discipline from the drop down list and click the Other Resources tab.
-
Click Import.
-
Navigate to the directory where you have the file saved and select it.
-
Restart Specify.
-
Select the new formatter 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.