KBA-01374: Using the @DV function in Doc 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 rules (KBA-01323) and Nested Bookmarks (KBA-01348) can help you define your computed fields. Many basic Spitfire bookmarks can include a DV prefix to print a described value instead of the original data, or for example, a vendor name instead of a vendor ID number. By combining several advanced document template features (Dynamic fields, Word Template Rules, and Nested Replacements), you can use custom DV functions in your templates. The only way to use this functionality is to use a computed string field with the @DV function and nested replacements. For example, let‘s consider accessing a date stored on the Vendor document when generating a template from a Commitment or CCO document.

  1. Define a dynamic computed field using a WordTemplateConfig rule; the value is a string and takes the form

=@DV( DVNAME, KeyValueExpression, Depends on list)

  • DVNAME is a Lookup Result Scalar Value name. Many are described in the Developer’s Primer.  Sites can create their own during implementation.  For our example, Spitfire ships with VendorDateStart, which can get us the necessary data.
  • KeyValueExpression is almost always a nested bookmark expression (in [ … ] ) to get some important value to pass to the DV, in this example dven_docheader_sourcecontact to get the Vendor ID for this Commitment.
  • Depends on list is optional and is determined by what the DVNAME needs.  In this example, VendorDateStart needs the GUID of the agreement date type. This value can be a constant as it is here, or it could be another [nested bookmark].  This example uses only one value; there can be others also separated by commas.
  • Hint: Be very careful not to include any extra spaces around the commas.

Your WordTemplateConfig rule  would look something like:

  • Rule name: DocMasterDetail.VAgreeDate
  • Filter Value: blank
  • Result Value: ‘=@DV( VendorDateStart,[dven_docheader_sourcecontact],01AB9D68-5F85-4CE6-A0B2-267F55341460)‘

Additional Comments:

There are several additional examples using @DV in the distributed rules. Adding computed fields and scalar result values to your Bookmark Templates can be challenging.  Spitfire offers training and/or consulting services to assist you in developing complex template solutions.


KBA-01374; Last updated: October 6, 2016 at 13:25 pm;
Keywords:  Word body templates