Using Lua in Custom Functions
Lua Functions
In the latest product updates in version 2019 and above, you can use Lua functions if the format uses RENDER=API.
Tip: Refer to Lua documentation for tips to get started with Lua scripting.
To use a Lua function in a format, the formats needs the line ‘RENDER=API’.
Add a section for the Lua function.
The section for the Lua function starts with >>> lua and ends with <<< lua
The example below checks if Ref is blank then the function returns first applied Invoice Number.
LUA function in EFT Formats.ini
>>> lua
function GetRef(Ref)
if Ref == "" then return GetField("FirstInvoiceNumber")
else return(Ref)
end
end
<<< lua
Using the function
You can then create a variable using the function
DRef is the variable where you call the function (GetRef) and pass the parameter, in this case the DestReference field.
DRef="[Eval(GetRef(Trim(GetField("DestReference"))))] "
Add the variable in the format definition
Lastly, use the variable on the line where you want it to be displayed.