Takes a string and replaces markers within it with the current value of a field or the value of a property within an, optional, supplied object.
Markers are in the form
By default all field values and object properties will be HTML escaped before embedding in the returned string. This can be disabled, but care must be taken to ensure that a user supplied value is not redisplayed, un-escaped, to other users. This could lead to a cross site scripting attack (XSS).
Repeating Pages
If the field you want to display the value of is on a repeating page, include the page instance in square brackets between the hash symbols, like this
The following tokens can also be used:
#PAGEINSTANCE# - The page instance that's currently being displayed (zero-based, ie the first instance is 0)#PAGEINSTANCEDISPLAY# - The user friendly current page instance (one-based, ie the first instance is 1)#PAGEINSTANCEMIN# - The minimum number of instances set in the forms designer#PAGEINSTANCEMAX# - The maximum number of instances set in the forms designer#PAGEINSTANCECOUNT# - The current number of instances (of this page) that have been generated
Arguments
Argument | Type | Description |
---|---|---|
template | String, required | The template text |
valueObj | Object, optional | A JavaScript object containing additional name values |
noEscape | Boolean, optional | True disables HTML escaping of values before embedding in template |
Returns
String
Example
The following function has been added to the top text input box called NAME.
function (helper, fieldName, value, valid, eventName) {
if (eventName == 'CHANGE') {
var msg = helper.utilExpandTemplate('Dear #NAME#,');
helper.setFieldValue('MESSAGE', msg);
}
}