Skip to content

Configuration Formatters

Thomas Trutt edited this page Apr 14, 2025 · 1 revision

Formatters are defined in YAMl files located in the config directory have been implemented to allow for end users manipulate the data that was returned by the FOLIO system. This is done by defining a series of reformat keys for both the charge and credit data.

formatters:
  charge_formatters:
    - ...
  credit_formatters:
    - ...

Reformatter format

vars:
  run_env: "TEST"
  trans_active: true

formatters:
  charge_formatters:
    -   filter_field: patron.externalSystemId
        type: LEFT_STRIP
        search_for: "0"
        replace_with: ""
        new_field: patron.externalSystemId
  credit_formatters:
    -   filter_field: patron.externalSystemId
        type: LEFT_STRIP
        search_for: "0"
        replace_with: ""
        new_field: patron.externalSystemId

Formatters are required to be in order, as they will be processed in the order listed. If you do not wish to use a reformatter, you can just leave the formatters array empty.

vars Fields

The vars section allows you to set variables that can be used in the jobs section. This allows you to set a variable once and use it in multiple jobs.

Fields

filter_field

  • The field that holds record that should be reformated

type

  • (options) LEFT_STRIP | RIGHT_STRIP | REPLACE
    • RIGHT_STRIP - This will remove the characters from the right side of the string as defined by the search_for field.
    • LEFT_STRIP - This will remove the characters from the left side of the string as defined by the search_for field.
    • REPLACE - This will replace the search_for string with the replace_with string.

search_for

  • What value should be searched for and/or what charter should be stripped from the left or right.

replace_with

  • Used with REPLACE type. What the value should be replaced with.

new_field

  • The field name where the changes are to be saved to. This can be the same value as the filter_field

Practical examples

Remove leading 0 from externalSystemId

At our institution our external ids are loaded with a leading 0. This is not needed by the bursar system and needs to be removed.

formatters:
  charge_formatters:
        -   filter_field: patron.externalSystemId
            type: LEFT_STRIP
            search_for: "0"
            replace_with: ""
            new_field: patron.externalSystemId

This will transform a value in patron.externalSystemId from 000123456 to 123456 If we wanted to remove leading and trailing 0's we could add another formatter:

formatters:
  charge_formatters:
    -   filter_field: patron.externalSystemId
        type: RIGHT_STRIP
        search_for: "0"
        replace_with: ""
        new_field: patron.externalSystemId

This would remove all leading and trailing 0's from the patron.externalSystemId field resulting in 123456 from 000123456000.

Removing ',' from the title field

Titles can have ',' in them but when converted to a csv file this can lead to errors. We can remove these with the following reformatter:

formatters:
  charge_formatters:    
    -   filter_field: title
        type: REPLACE
        search_for: ","
        replace_with: ""
        new_field: title

This will reformat the title "Apples and Oranges, How to tell the difference" to "Apples and Oranges How to tell the difference".

Clone this wiki locally