Toggle menu

helper.utilExpandTemplate(template [, valueObj] [, noEscape])

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 #name# where name is the name of a field or a property within the supplied valueObj.

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 #NAME[1]#.

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


templateString, requiredThe template text
valueObjObject, optionalA JavaScript object containing additional name values
noEscapeBoolean, optionalTrue disables HTML escaping of values before embedding in template




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);

Share this page

Facebook icon Twitter icon email icon


print icon