NiFi Ingest 25.2
NiFi Ingest

# Write and Debug Lua Scripts

You can use the advanced configuration interface of the ExecuteDocumentLua processor to write and debug Lua scripts.

If you plan to write a large amount of code you can divide it into modules. This is especially useful if you write functions that can be re-used in different places. To add a new module from within the advanced configuration interface, click in the Scripts area. This adds a new dynamic property with your code as the value. To delete a module, find the module in the Scripts area and click .

After making changes to the script in the Lua code area, click SAVE to save your changes. If your Lua script was loaded from a file and Overwrite script files is selected, the original file is overwritten. If your Lua script was loaded from a file and Overwrite script files is not selected, the value of the relevant property (Lua script file for the main script, or a dynamic property for optional modules) is overwritten with the new code.

The interface also includes a Move To File button that you can use to move code entered as a property value into a script file on disk. Your Lua script must be stored in a file if you want to use the debugging features.

## Code Samples

A selection of code samples is available from the LUA SAMPLES tab. You can copy these into the Lua code area and modify them as necessary.

## Debug Lua Scripts

TIP: When debugging a Lua script, OpenText recommends that you:

- Process one FlowFile at a time. For example, configure a GenerateDocumentFlowFile processor to provide sample input to the ExecuteDocumentLua processor.
- Configure the ExecuteDocumentLua processor to run only one concurrent task. (You can configure the number of concurrent tasks in the Scheduling tab when configuring the processor).

When the ExecuteDocumentLua processor is stopped, you can open the advanced configuration interface and add breakpoints to your script. To add a breakpoint, click in the margin next to the line number. A red circle indicates a breakpoint.

After adding one or more breakpoints, start the processor. Then, return to the advanced configuration interface and click the DEBUG tab. The status of each concurrent task is shown at the top of the DEBUG tab. In the example below the processor is processing four documents concurrently (which is not recommended while debugging) and in each case the script has stopped at the breakpoint.

Below the list of sessions, you can see the following information:

- The BREAKPOINTS tab displays a list of breakpoints. To remove a breakpoint, click Delete .
- The STACKTRACE tab shows the call stack, the list of functions that have been called to reach the current point in the code. The functions are listed in reverse order (the last function that was called appears first).
- The LOCALS tab shows the values of local variables at the current point in the code.

After examining the information in the DEBUG tab, you can perform one of the following actions. Click one of the sessions to select it, and then:

- To step over lines of code, click Step . This runs one line of code at a time. In the Lua code area, a green arrow indicates where the script has stopped. For example, after stepping over two lines the Lua code area might look like this:

- To continue running the script, click Continue . The script runs to completion, unless it encounters another breakpoint.
- To clear all breakpoints, click Clear breakpoints .
- To modify the Lua script, for example to fix a problem that you have found, you must first stop the ExecuteDocumentLua processor. OpenText recommends that you allow all of the scripts to finish and the incoming queue to become empty before stopping the processor.

Copyright 2018-2025 Open Text
Version 25.2 | Last updated April 2025

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: Knowledge Discovery NiFi Ingest 25.2

Topic Title: Write and Debug Lua Scripts