# Export Jobs

Orderwave makes it easy to export data to partners. Whether you're sending data to a FTP/SFTP server, or pushing data to a web-service URL, you can format the data as needed, find the data you need, and send it where you want.

To get started, you’ll want to follow these recommendations for setting up a programmatic export process.

  • Create queues
  • Create rules
  • Create a destination (web service or file transfer location)
  • Create data transformation template
  • Create an automated task

Example 💡

In the following sections, let's use the example that you need to set up a daily export of orders to your finance team.

# Create Queues

Though not strictly necessary, this is recommended (you can also export data based on saved search filters). Queues give you programmatic control for which items in a bucket to export, and give you added control to account for errors and successful exports.

First, you will want to create a queue that denotes that the item in the bucket should be exported. Using the example that we're exporting orders to your finance team, you can create a new queue with the queue-code FINANCE-ORDER-EXPORT. Feel free to name/describe the queue properties so that your team can easily understand it.

Next, you will want a queue that denotes that the order could not be exported in the event of an error. This will help you track down these orders later. Create a queue with the queue-code FINANCE-ORDER-EXPORT-ERROR. We recommend that this queue be a blocking-queue, so that these orders are not exported again until they are reviewed.

# Create Rules

Next, you need to decide what qualifies these orders to be exported. For this example, let's use the trigger markComplete, since the finance team usually only cares about completed orders. If you want to export all orders that are marked complete, you can use a simple "always true" type of rule condition, such as field: id operator: more compare: 0 (this just says that the id is greater than zero, which is always true for data in Orderwave). For the rule action, choose to add the queue FINANCE-ORDER-EXPORT.

Now you have a rule that will queue-up all completed orders to be exported to finance.

# Create a destination

Export jobs can export data to a FTP/SFTP server or a web-service. Depending on where you want to send the orders, create the appropriate Web Service or File Transfer Location. Both Web Services or File Transfer Locations are setup to be reused across Orderwave, so that you don't need to maintain credentials in too many places. Don't worry about folder-paths or other details when setting these up - these will be configured later in your Automated Task.

TIP

If you do not want to export to a web-service or server, you can skip this step. You can run your automated task on-demand and simply download the file. If sharing data with partners, we recommend a web-service or FTP/SFTP server be used, so that your partners can access the data easily and programmatically.

# Create a Data Transformation Template

This step is not strictly necessary; if you want to simply work with all of the data, directly in Orderwave's formats, you do not need a Data Transformation Template. Data Transformation Templates help you transform the data from Orderwave's format to the format that you need for your partner, such as your finance team. This is accomplished by the use of Handlebars templates.

Handlebars is a template language that will let you describe the final output of the data. Using the template language, you can create XML, CSV, JSON, or any other data file format.

TIP

When you do not use a Data Transformation Template, the data will be exported directly in Orderwave's default JSON data format. Refer to our API documentation for data formats.

# Create an export job

Finally, you will use the elements from above to create an Automated Task that runs a Export job.

Start by creating a new Automated Task with the recurrence properties you need. In our example, you will set this task to run with a frequency of 1 and a recurrence of Day; set the start-on field to the date and time that the task should start running. After you create the Automated Task, set the task properties by choosing Export job as the task type.

Using our example of exporting orders, you will want to use the bucket oms/orders.

Use the Queue option, and select your FINANCE-ORDER-EXPORT queue. We're telling this export job to export orders in that queue. You see that Orderwave alerts you that "When selecting a queue, 'non-blocking' will also be selected" - this helps you ensure that any order (or bucket item) that is currently blocked (in a blocking queue) will automatically be omitted from this export. This helps you determine that orders with problems will not be exported to partners.

In step two, you choose how to transform the data. If sending data to a FTP/SFTP server, you can specify your file-naming convention here in the file naming template. You can use Handlebars syntax for this name to help you create custom file names. You can reference the following fields in your template string:

Field Description
{{timestamp}}
A timestamp field in the format of YYYYMMDDHHmmss
{{datestamp}}
A date stamp field in the format of YYYYMMDD
{{taskCode}}
The task identifier you gave to this automated task

An example file naming template that creates a unique file name might be: Finance-Export-{{taskCode}}-{{timestamp}}.xml.

Choose your data transformation template (if needed) and move on to the third step.

Finally, choose your remote service to send the data to. This will be your Web Service or File Transfer Location that you set up before. Here, you can specify details, like folder path and HTTP method.

Now you can specify queue and tag handling options for the export. Using our example, if the orders encountered an error, add to queue FINANCE-ORDER-EXPORT-ERROR.

If the orders exported successfully, remove from queue FINANCE-ORDER-EXPORT, so they will not be exported again (unless you queue them to export again).

# Conclusion

Now you have a fully programmatic data export strategy that:

  • Isolates the records to export
  • Identifies them and queues them based on custom logic
  • Centralizes remote data locations
  • Transforms the data to partner specifications
  • Automates the export process
  • Gracefully handles errors
  • Dequeues data from the export process when exported successfully