Skip to main content
Conga Support

How to Use Bookmarks, References and If Statements in Word Templates (Release 7)

Using Word®'s Bookmark feature is especially handy when some piece of data or text needs to be referred to at another point in the document. Reference fields make formula fields (e.g. if statements) simpler to read and also make changing formulas in the future more manageable as a single Reference field change that is referenced many times throughout a document takes only one update.  Here we explain how to insert Word Bookmarks, add Word References, and use those features within an if statement to get to a desired output.

Notes:
  • If a formula field can be written in Salesforce® to accomplish the same logic as what is outlined below, that is the preferable option rather than doing so in the Word template.
  • Ensure that each component of the if statement is surrounded by quotation marks ("). If the data within a merge field contains a quotation mark (") character, the if statement will not work and the source data in Salesforce must be changed to remove the offending quotes.


Inserting Bookmarks:
  1. Select the entire data block (merge field or static data) and go to the Insert menu.
     
  2. Choose Bookmark.
     
  3. Type in a name for the Bookmark (a simple name is best; spaces are not allowed).
     
  4. Click Add.
     
  5. Repeat as necessary for other Bookmarks.


Adding References:
  1. Place your cursor in the desired location for the reference to appear.  Go to the Insert menu.

  2. Click QuickParts > Field.

  3. Choose the Ref option (Alt+I, F, R, R is the keyboard shortcut).

  4. Select the appropriate Bookmark to Reference and click OK.

  5. That Reference is now created.





Writing an IF Statement in Word:
  1. Insert > Quick Parts > Field, or use the keyboard command Alt + I, F.

  2. Choose IF from the field list and click OK.  You will receive an error in Word, "Error! Missing test condition."  Ignore this, as we will fix it in the following steps.

  3. Right-click on the new IF field and choose Toggle Field Codes.

  4. Delete everything inside of the field other than "IF." The field should look like this:  { IF }

  5. Inside of the IF, add Expression1 - this can be a merge field, static text, Bookmark, or Reference inside of quotes.  Bookmarks and References can be inserted within the if statement by following the same instructions outlined above. 
    { IF "«Manager_Name»" }

  6. Enter your Operator next, followed by Expression2 (again, this can be a merge field, static text, Bookmark, or Reference): 
    { IF “«Manager_Name»" = "Test Testing" }
     

  7. Next, add TrueText inside of quotes.  This is what will display when the if statement evaluates as true; here we have simply placed the quotation marks and nothing else, indicating the TrueText will be nothing/null:
    { IF “«Manager_Name»" = "Test Testing" "" }
     

  8. Finally, add the FalseText inside of quotes.  This value will display when the if statement evaluates as false; here we've used a combination of the Ref field and static text.
    { IF “«Manager_Name»" = "Test Testing" "" "«Manager_Name» has been recognized as an outstanding individual." }

  9. Expand the entire IF Statement and its components by Toggling Field Codes (Right-click on the field > Toggle Field Codes or Alt + F9).
    { IF “{ REF Manager_Name \* MERGEFORMAT }" = "Test Testing" "{ REF Manager_Name \* MERGEFORMAT } has been recognized as an outstanding individual." "" }

  10. To collapse the IF Statement, right-click on IF and choose Toggle Field Codes once more. Note: Selecting Update Field instead of Toggle Field Codes will display the FalseText result from your if statement.

  11. In the above example, if the Manager Name in Salesforce is Test Testing, Word will display nothing.  However, if the Manager Name is anything other than Test Testing, Word will display the manager's name followed by the text, "has been recognized as an outstanding individual."