TransformScript
Files TransformScript is a language built into Files.com for transforming and reshaping file data as it moves through your workflows. This lets you convert and clean up data at the moment files cross between partners and systems, without sending them out to a separate integration tool first. You write a short script that reads an incoming file, changes it into the shape another system expects, and produces a new file. Run it in an Automations v2 Transform node, subject to the v2 beta terms, or as a one-off Transform File action.
Files rarely arrive in the exact format the next system needs. A partner sends CSV when your application wants JSON, field names don't match, dates use the wrong format, or one document has to become many records. TransformScript handles that translation in place: read the file in one format, enrich and restructure it, and write it back out in another.
TransformScript also works with Expectations to check a file's contents rather than change them. Content Validation criteria run your custom script to determine whether data matches your requirements.
TransformScript is one of several Files.com features for processing files automatically.
What You Can Do With TransformScript
A TransformScript reads a file, transforms it, and writes the result. Within that, you can:
- Convert between formats such as JSON, CSV, XML, YAML, and the EDI and HL7 standards used in business and healthcare.
- Reshape records into the exact structure a downstream system expects, renaming fields and restructuring nested data.
- Normalize and enrich values, standardizing dates, currencies, and identifiers, or adding context from earlier workflow steps.
- Filter, group, join, and aggregate records.
- Apply business-level error-checking logic through content validation, before files reach downstream processing.
- Call AI to extract structured fields from messy input, classify documents, or summarize content, with the result fed back into the workflow. AI in TransformScript is in Limited Preview; contact your Account Manager for access.
The Shape of a TransformScript
A TransformScript has a header for settings such as the output format, a --- separator, and an expression that produces the result:
%files 1.0
output json
---
{ message: "Hello, " ++ payload.name }
The expression after the --- is where the work happens. It reads from a small set of inputs and builds the output you want. For the full structure, see Writing a TransformScript.
The Inputs You Work With
payload contains the input data: a JSON object, an array of CSV rows, or a structure of EDI segments, for example. Additional bindings depend on where the script runs. In an Automation, attributes describes the current item; TransformScript in Automations defines those bindings. Expectation scripts receive either one file's contents or the whole batch.
Files.com parses the input and serializes the result using the script's input and output formats.
Editing and Testing Scripts
You write and edit TransformScripts in the Files.com web interface or through the API. The browser-based editor lets you run a script against sample input and see the output immediately, so you can build and validate a transformation before putting it into a live workflow.
The AI Assistant works inside the editor, so you can describe what you need and have it write the script.
Common Use Cases for TransformScript
Customers use TransformScript wherever incoming files have to be reshaped before another system can use them. Finance teams convert partner remittance files into the record layout their accounting system imports. Healthcare organizations translate HL7 messages into JSON for an internal application. Retailers normalize sales feeds from many stores into one consistent schema. Logistics partners exchange EDI purchase orders and invoices and map them to and from internal formats.
For examples you can adapt, see the Cookbook.
Comparing TransformScript to Related Features
TransformScript reshapes the contents of a file. Automations orchestrate the steps around that transformation, while Expectations can use the same language to validate a delivery.
TransformScript vs. Automations
Automations v1 move, copy, rename, and organize files. Their expressions can calculate destination paths, but their file actions do not rewrite file contents. Automations v2 can run a TransformScript in a Transform node, then deliver the resulting data or file to later nodes. The script defines the data transformation; the Automation defines when it runs and what happens next.
TransformScript vs. iPaaS Integrations
Files.com integrates with iPaaS platforms such as Boomi, Mulesoft, and Zapier. Those platforms transform data in a separate system, after the file leaves Files.com. TransformScript does the transformation inside Files.com, at the point of transfer, so you don't stand up and maintain a separate pipeline for format conversion and field mapping. Use an iPaaS integration when the work belongs in a broader external workflow you already run there; use TransformScript when you want the transformation to happen in place.