Script Methods for Accessing the Data Map at Runtime
The data available or generated when Loftware Enterprise™ SP responds to a print request is stored in a data map. Each data map entry consists of a name (also called a key) and a value. You can use a Script data source to access and alter data in the data map after a print request is submitted but before printing occurs. By using a Script data source to access the data map, you can check for the existence of a data map entry by using its fully-qualified name, retrieve the value of a data map entry, change the value of a data map entry, and add new data map entries.
Note: The data map can also be accessed and modified by using a business rule. If a business rule and a Script data source both modify the data map, the Script data source is evaluated last.
Tip: If using these script methods in a business rule, select the Rhino script engine.
You can access and modify data in the data map by using the following methods:
Note: In the following methods, Name must be the fully-qualified name of a data map entry, such as the name of a field or a data source. NewValue must be a text string.
About the syntax documentation
Method |
Return Value |
Description |
---|---|---|
keyExists(Name) |
Boolean |
Determines whether the data map contains is an entry for the specified name.
Example var dataMapEntryExists = MAP.keyExists("/Body/Text0001"); |
putValue(Name, NewValue) |
Adds a data map entry or updates the data map entry associated with the specified name by changing the value of that data map entry to the new value. Example MAP.putValue("/Body/Text0001", "New Field Value"); |
|
getValue(Name) |
Node |
Retrieves the value of the specified data map entry interpreted as a node value. Null is returned if the name does not exist. Example var nodeVal = MAP.getValue("/Body/Text0001"); |
getNodeType() |
String |
If a data map entry has been retrieved by using getValue, this method retrieves the data type of the data map entry. Example var nodeVal = MAP.getValue("/Body/Text0001"); |
getStringValue(Name) |
String |
Retrieves the value of the specified data map entry interpreted as a string value. Null is returned if the name does not exist unless a default value is specified using the method getStringValue(Name,DefaultValue). Examples var stringVal = MAP.getStringValue("/Body/Text0001"); var stringVal = MAP.getStringValue("/Body/Text0001", "MyDefaultValue"); |
getIntegerValue(Name) |
Integer |
Retrieves the value of the specified data map entry interpreted as an integer value. Null is returned if the name does not exist unless a default value is specified using the method getIntegerValue(Name,DefaultValue). Examples var integerVal = MAP.getIntegerValue("/Body/Text0001"); var integerVal = MAP.getIntegerValue("/Body/Text0001",10000001); |
getDoubleValue(Name) |
Double |
Retrieves the value of the specified data map entry interpreted as a double-length integer value. Null is returned if the name does not exist unless a default value is specified using the method getDoubleValue(Name,DefaultValue). Examples var doubleVal = MAP.getDoubleValue("/Body/Text0001"); var doubleVal = MAP.getDoubleValue("/Body/Text0001",10000222); |
getDateValue(Name) |
Date |
Retrieves the value of the specified data map entry interpreted as a date value. Null is returned if the name does not exist unless a default value is specified using the method getDateValue(Name,DefaultValue). This method is useful for taking a binary DATE value from a Database data source, and converting it to a human readable date value. This method should only be called using a data source name parameter that has the DATE data type and has data values that are binary. The returned date is in the following format: EEE MMM dd hh:mm:ss z yyyy The following is an example of a date using this format: Mon Mar 26 00:00:00 EDT 2012 For more information, see Time Values in Loftware Enterprise SP. Examples var dateVal = MAP.getDateValue("/Body/Text0001"); var dateVal = MAP.getDateValue("/Body/Text0001",Date.now()); |
getBinaryValue(Name) |
Byte array |
Retrieves the value of the specified data map entry interpreted as a byte array value. Null is returned if the name does not exist unless a default value is specified using the method getBinaryValue(Name,DefaultValue). Examples var binaryVal = MAP.getBinaryValue("/Body/Text0001"); var binaryVal = MAP.getBinaryValue("/Body/Text0001",array); |
getBooleanValue(Name) |
Boolean |
Retrieves the value of the specified data map entry interpreted as a Boolean value. Null is returned if the name does not exist unless a default value is specified using the method getBooleanValue(Name,DefaultValue). Examples var booleanVal = MAP.getBooleanValue("/Body/Text0001"); var booleanVal = MAP.getBooleanValue("/Body/Text0001",true); |
setValue(NewValue) |
If a data map entry has been retrieved by using getValue, this method changes the value of the data map entry to the specified value. Example var nodeVal = MAP.getValue("/Body/Text0001"); |