Skip to main content
jasonb1005
September 2, 2023
Question

Conditional statements in DocX

  • September 2, 2023
  • 2 replies
  • 0 views

I'm trying to populate conditional dynamic data in my docX. I have regular data populating fine, but I can't seem to find the correct syntax for conditional statements. Here's what I have so far that keeps evaluating to false:
{if "<<${doc.center.subjectType}>>" = "Individual" "Is Individual" "Not Individual"}

Anyone know what's going wrong here? or where I can find documentation on this?

Thank you

    2 replies

    mathieud0001
    Brainy
    September 2, 2023

    I usually try to avoid putting the if/else logic inside the word document. I simply have a placeholder and manage the condition in the expression that generates the XML.

    harshm4411
    September 2, 2023

    If/else-conditions in .docx templates:

    Syntax

    The syntax needed is pretty simple:

    {if”<>”=”XY” “Content if condition is fulfilled” “Content if condition is not fulfilled”}

    while the yellow part marks the condition, the green part marks the content that will be printed if the conditions is fulfilled and the red part marks the content that is printed if the condition is not met.

    Link for your reference: 
    https://support.mscrm-addons.com/knowledgebase/if-else-conditions-in-docx-templates/