Object
Objects are multi-level structured data types that can hold many different values within the same single variable. The Object data types are only available natively in the DataMapper module. The Object data type is actually a JSON object, with some basic types available for each property added to it. For more information on JSON Objects, see JSON DataTypes on TutorialsPoint.
Defining Objects
- Preprocessor: Create a new Property and specify the "Type" as "Object".
Setting the Object Values
In the current implementation of the Object data type, the Default Value cannot be used to specify the contents of of the Object. In order to actually specify the value, there are two different methods.
- For the Each Record
scope: the value can be defined within an Action Step using
JSON.parse(). Here is an example:
JSON.parse('{"foo":"bar"}');
- For the Entire Data and Automation scopes: the values should be
defined in a Preprocessor script. The script is very similar to the
previous one, with the added addition of defining which property to
change:
data.properties.MyDataProp = JSON.parse('{"foo":"bar"}');
PlanetPress Workflow automation
variables and job informations are also available in the Preprocessor
scripts. Simply replace the literal JSON string with a call to the automation
object, for example data.properties.MyJobInfo9 = JSON.parse(automation.jobInfo.JobInfo9);
Using Objects in the DataMapper
Whenever an object is available within the DataMapper, it can be accessed throughout the configuration and for each record.
Example JSON Object structure for an object called "MyDataProp"
:
{"menu": { "id": "file", "value": "File",
"visible": false, "popup": { "menuitem": [ {"value": "New", "onclick": "CreateNewDoc()"}, {"value": "Open", "onclick": "OpenDoc()"}, {"value": "Close", "onclick": "CloseDoc()"} ] } }}
Accessing this object from any JavaScript expression is done through
the appropriate property call. For example, data.properties.MyDataProp.menu.id;
would return the value file , and data.properties.MyDataProp.menu.visible;
would return the boolean value false.