Use this option when a custom field has no computed content, and the content is provided exclusively using a Lua script. This is a special type, designed to prevent the editing of raw content and restricting the user interface to applicable field options.
Any existing field content is cleared before the script is executed to ensure consistency each time content is built.
A script called createformattedcontent.lua should be placed in the data sources ‘Scripts’ folder. Here’s a simple example which numbers ‘sample field’ with the index of each record in the data source:
1 2 3 4 | recordset = DATASOURCE.get():getrecordset(); for i = 1, recordset:size() do recordset:getrecord(i):field("sample field"):setformattedcontent(i); end |
It should be noted that this setting is only applicable to fields which have no content. The script can also be used to modify the content of any field. For example, here is a Regular custom field – the script modifies its formatted content:
1 2 3 4 5 | recordset = DATASOURCE.get():getrecordset(); for i = 1,recordset:size() do existing_content = recordset:getrecord(i):field("sample field 2"):content(); recordset:getrecord(i):field("sample field 2"):setformattedcontent(existing_content .. "/" .. existing_content); end |
In this case, all fields options, cleansing, prefix, suffix, etc are applied before the script is executed.