Open topic with navigation

# 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 HPE 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 HPE 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.

© 2017 Hewlett Packard Enterprise Development LP | Send documentation feedback to HPE Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a web mail client, and send this email to AutonomyTPFeedback@hpe.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_HP_HTML5_bannerTitle.htm