KBA-01393: Using the @HasData Function in Template Computed Fields

Summary:

Spitfire‘s templates created in Microsoft Word offer the ability to dynamically compute new values based on existing data in the document. The WordTemplateConfig rule group (KBA-01323) and Nested Bookmarks (KBA-01348) can help you define your computed fields.  Fields of data are referenced in [alias_field] format which is fully described in the Focus on Bookmark Templates guide. Occasionally, it is useful to make a bookmark replacement conditional on the existence of data in a specific document alias.  For example, you may want to indicate a Contact name using one or another project role.

When processing a computed field, the field definition is scanned for =@HasData(aliasName).  This embedded function is replaced with TRUE if the specified alias has data, or FALSE otherwise.

You might define a computed field such as the one below using a WordTemplateConfig rule:

  • Rule: DocAddr_ECPerson   (for emergency contact person)
  • Result Value: IIF(=@HasData(APMADDR), ‘[APMADDR_Person]‘, ‘[PMADDR_Person]‘)

KBA01393_01

Then place a bookmark in your template in Microsoft Word, for example:

In case of emergency, please contact [PMADDR_ECPerson].

If the project has an alternate PM, their name will print. Otherwise the PM‘s name will print.

Additional Comments:

Remember: Your computed field definitions are only loaded and processed if the alias on which they are used has data.  So if both the APM and PM are conditional, a more complex structure using a third address alias would be required.  The template should always reference a bookmark alias that has data.


KBA-01393; Last updated: October 20, 2016 at 12:07 pm;
Keywords:  =@HasData;HasData