Skip to content

Configuration Exporting

Thomas Trutt edited this page Jul 18, 2025 · 2 revisions

The export function allows you define what templates should be used, the data it should be processed against and where the resulting file should be saved/ sent.

Export field format

vars:
  run_env: "TEST"
  trans_active: true

export:
    - file_name: "charges_{{format_date 'NOW' '%Y%m%d'}}.csv"
        template_name: "charges"
        template_data: "CHARGE_DATA"
        export_type: "AwsBucketExporter"
        export_to: ""
        connection_name: "AWS_1"
        comment: "this is used slack"
        attachment: false

NOTE: At the time of writing all files are saved to the local system. This will be changed to allow sending of files as well as saving to the local system

Exports are required to be in order, as they will be processed in the order listed. If you do not wish to use a export, you can just leave the export 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

file_name

  • The name that the file should be saved as. This can include the handlebars function {{format_date 'now' '%y%m%d'}} to include the current date in the file name.
    • The date can be entered as follows: {{format_date 'NOW' '%Y%m%d'}}.
    • Example: charges_{{format_date 'NOW' '%Y%m%d'}}.csv will result in a file name of charges_20220222.csv.
  • The file name should include the file extension.

template_name

  • The name of the template that should be used to process the data. This should match the name of the template in the templates directory.

template_data

  • (options) CHARGE_DATA, REFUND_DATA or All_DATA
    • The data that should be processed by the template.
    • CHARGE_DATA will send the charge data only to the template.
    • REFUND_DATA will send the refund data only to the template.
    • BOTH will send CHARGE_DATA or REFUND_DATA data to the template. This should only be used when you need to include both charge and refund data in the same template. Otherwise you should use the CHARGE_DATA or REFUND_DATA options.
    • PROCESS_DATA This is the data for the item that have been processed against FOLIO by the system.
    • ALL_DATA will send all data returned by the API, including the PROCESS_DATA.

export_type

  • (options) AwsBucketExporter, EmailSmtpExporter, EmailMicrosoftExporter, SfptExporter or LocalExporter
    • The type of export that should be used. This will determine where the file is saved.
    • AwsBucketExporter will save the file to an S3 bucket.
      • The _SECURE flag on the AWS environment variable will determine if the connection is secure or not.
        • false is used when this code is being ran as a lambda and does have direct access to the S3 bucket.
        • true is used when this code is not being ran as a lambda and does not have direct access to the S3 bucket.
    • SfptExporter will save the file to an Secure FTP server.
    • LocalExporter will save the file to the local system.
    • EmailMicrosoftExporter will send an email with the option to add attachments using Microsoft 365.
    • EmailSmtpExporter will send an email with the option to add attachments using SMTP protocol.
    • SlackExporter will send an message with the option to add attachments using Slack.
    • BoxExporter will save the file to a Box account.
    • OneDriveExporter will save the file to a OneDrive account.

_ All types except for LocalExporter will require the connection_name field to be set to the environment variable that contains the connection string for the export type._

export_to

  • The location that the file should be saved to. This will depend on the export_type that is used.
    • AwsBucketExporter - Not used
    • SfptExporter - Not used
    • LocalExporter - The local directory that the file should be saved to. This is relative to the server base directory.
    • EmailMicrosoftExporter or EmailSmtpExporter - The email address that the email should be sent to. This will be used as the to field in the email.
    • SlackExporter - Not used
    • BoxExporter or OneDriveExporter - The folder name that the file should be saved to. This is relative to the root of the Box or OneDrive account.

connection_name

  • This is the start of the environment variable that contains the connection string for the export type. Example: AWS_1_ACCESS_KEY_ID would be AWS_1

comment

  • This is a comment that will be used when sending the file to Slack. This will be used as the message that is sent with the attachment.
    • This is only used when the export_type is set to SLACK.

attachment

  • (options) false or a list of attachments
    • false This export will generate a single file (all but the email type)
    • When using the email export type, this will be a list of attachments that should be sent with the email. It uses the same format as the export settings.

templates

Templates are used to process the data that is returned by the processing system. These are handlebars templates that are saved to the templates directory. more information can be found in the templates documentation.

Practical examples

Export all charge data to a CSV file

export:
    -   file_name: "charges_{{format_date 'NOW' '%Y%m%d'}}.csv"
        template_name: "charges"
        template_data: "CHARGE_DATA"
        export_type: "AwsBucketExporter"
        export_to: ""
        connection_name: "AWS_1"
        attachment: false

This will result in a file being saved as charges_20220222.csv with the data being processed by the charges template and only the charge data being processed.

Export a file and send is as an email attachments

export:
    -   file_name: "Report summary {{format_date 'NOW' '%Y%m%d'}}"
        template_name: "email_body"
        template_data: "CHARGE_DATA"
        export_type: "EmailMicrosoftExporter"
        export_to: "james@institution.com"
        connection_name: "MICROSOFT_1"
        attachment: 
            -  file_name: "charges_{{format_date 'NOW' '%Y%m%d'}}.csv"
                template_name: "charges"
                template_data: "CHARGE_DATA"

In this example a few things are happening:

  • The file_name field, Report summary {{format_date 'now' '%y%m%d'}}, is used to generate the email subject line.

  • The template_name field, email_body, is used to generate the body of the email.

  • The export_to field, james@institution.com, is the address that the email will be sent to.

  • The attachment field is used to generate attach the file that is generated by the charges template. This will be saved as charges_20220222.csv and attached to the email.

Note: When defining attachments the export_type, export_to and connection_name fields are not used.

Export a file and send it in a Slack message

export:
    -   file_name: "Report summary {{format_date 'NOW' '%Y%m%d'}}"
        template_name: "email_body"
        template_data: "CHARGE_DATA"
        export_type: "SlackExporter"
        export_to: ""
        connection_name: "SLACK_1"
        attachment: 
            -  file_name: "charges_{{format_date 'NOW' '%Y%m%d'}}.csv"
                template_name: "charges"
                template_data: "CHARGE_DATA"
                comment: "this is my comment for slack"

In this example a few things are happening:

  • The file_name field, Report summary {{format_date 'now' '%y%m%d'}}, is used to generate the slack message subject line.

  • The template_name field, email_body, is used to generate the body of the slack message.

  • The attachment field is used to generate attach the file that is generated by the charges template. This will be saved as charges_20220222.csv and will be sent to Slack as an attachment.

  • The comment field is used to add a comment that will be used as the message that is sent with the attachment.

Note: When defining attachments the export_to field is not used.

Clone this wiki locally