Write a Lua Script

Your Lua script must have the following structure:

function handler(document)
   ...
end

The handler function is called for each document and is passed a document object. The document object is an internal representation of the document being processed. Modifying this object changes the document.

For CFS to continue processing the document, the function must return true. If the function returns false, the document is discarded.

The script can also terminate due to an error, for example if you use the Lua error function or call a Lua function that causes an error. In this case CFS continues to process the document, but places an error message in the ImportErrorDescription field.

TIP: You can write a library of useful functions to share between multiple scripts, which you can then include in the scripts by adding dofile("library.lua") to the top of the lua script outside of the handler function.