You can use format conversion to configure automatic formatting for extracted index fields. This allows you to save the time and effort of changing the format by hand. Format conversion occurs after extraction, and is saved to the batch.xml file.
Use Cases
Here are some common use cases for format conversion:
- Assign prefixes and suffixes to document level fields
- Swap dates to desired format
- Swap uppercase and lowercase
- Normalize common data elements
- Replace words or values
- String truncating
- Reformat regular expressions with regex groups
Prerequisites
You will need to add the FORMAT_CONVERSION_PLUGIN to either of the following locations:
- As the last plugin in the Extraction module
- As the first plugin in the Export module.
Important: Only add the plugin to one of the modules. Ensure the Format Conversion Switch is set to ON. For more information on adding plugins, refer to Module/Plugin Configuration.
Configuration
Format conversion is configured at the index field level.
- From the Batch Class Management screen, open your batch class.
- Go to Document Types > [your document type] > Index Fields > [your index field] > Format Conversion.
Figure 1. Format Conversion
- Select one or more format options and configure the formation conversion rule.
Refer to the table below for a list of format options and their descriptions.
Format Option | Description | ||||||||
Prefix | Use this option to add any value before the extracted value.
Example format conversion:
|
||||||||
Suffix | Use this option to add any value after the extracted value.
Example format conversion:
|
||||||||
Replace | Use this option to replace any character in an extracted value with another character.
Note: The regex for an empty space is ‘\s’.
Note: You can create multiple replace rules by clicking the plus icon (+). Example format conversion:
|
||||||||
Change Case | Use this option to change the case of the extracted value to either lowercase or uppercase.
Important: If multiple format options have been configured, change case will execute before prefix or suffix formatting. Example format conversion:
|
||||||||
Sub String | Use this option to specify a portion of a string of text to be extracted. You will need to specify the start index and end index of the part to be extracted.
Example format conversion:
Note: To use a single character from the extracted value, specify the same value for the start and end index. |
||||||||
Change Currency | Use this option to convert extracted currency to a selected currency type.
Note: You can add or remove currency codes from System Configuration > Currency Configuration. Example format conversion:
|
||||||||
Fetch Named Group | Use this option to assign a capturing group a name for later back-referencing.
You can define how the extracted data needs to be formatted by using the regex group name. In the image above the value (123; 45; 6789) has been extracted using the following regex: (\d{3}.+(\d{2}).+(\d{4}) If the named regex is configured as $1-$2-$3, where $1 is a reference to capture group 1 and anything else is considered a constant value, the final value saved in the batch.xml file is 123-45-6789. |
||||||||
Date Conversion | Use this option to define any date format for a date index field.
Example format conversion:
You can define the date formats you want to be displayed in the format-conversion.properties file located at [Ephesoft_Directory]\Application\WEB-INF\classes\META-INF\dcma-format-conversion\format-conversion.properties. Make your changes to the formatconversion.date_formats= property. For more information on standard date formats, refer to this Java tutorial. |
Note: Change Currency and Date Formatting do not work with other formatting options. If one of these options are selected, all other options are disabled.
Test Format
You can test the format in the Test Extraction screen for your batch class.
- Open your batch class and go to Document Types.
- Click Upload Test Extraction File(s) or drag and drop files to the upload area.
- Click Test Extraction.
- Use one of the following configuration methods to test format conversion:
- Set Workflow to ON and select Format Conversion as the extracted plugin.
- Set Workflow to OFF and set Format Values to ON.
Conclusion
This completes an overview of how to use format conversion to configure automatic formatting for extracted index fields.