Augmenting Datasources via “CreateContent.lua”

Incoming data can be manipulated via a script which is executed before EasyCatalog attempts to load data from a data source. A ‘createcontent.lua’ script, located in the data sources scripts folder,  is called immediately before data is loaded. The script is passed a ‘records’ variable which is a RECORDSET object.

Take this data for example:

simple example.xls

field 1 field 2 field 3
1 A A
2 B B
3 C C
4 D D
5 E E

When loaded into EasyCatalog, with field 1 as the key, it looks like this:

When implementing the following ‘createcontent.lua’ script:

The result after synchronizing is:

Notice the indicators on the fields that didn’t originate from the original data. Fields created in this way are treated as regular fields, with the exception of tabular fields which are stored in binary format within the snapshot file.

The advantage of this technique over using ‘createformattedcontent.lua’ is that data is manipulated before its loaded, so content changes affect the actual content of a field. It also doesn’t impact on the rebuilding of formatted content, so only happens each time the data is synchronized.  In addition to this, content changes (updated, deleted) can be indicated.