Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Conditional statement in CRM Word template based on field value

Posted on by Microsoft Employee

I am having a problem with word templates.

First I created CRM document template and then I added required fields from XML Mapping Pane as Content Controls (plain text).

Then I created a rule inside a Word template to only show field if it contains a value, and if it is empty to hide it

{ IF <<field_name>> <>"" <<field_name>> }

This is working just fine.

Now I want to create a new conditional rule inside a Word template which is based on field value – if a CRM field value is equal to 24 months then write text 24 months, else write text unlimited.

{IF <<duration>> = ”24 months” “24 months” “unlimited”}

I don’t know if there is some syntax problem with my conditional statement, but this is not working. 

Does anyone have an idea how to solve this?

*This post is locked for comments

  • tomasipaolo Profile Picture
    tomasipaolo 10 on at
    Conditional statement in CRM Word template based on field value
    Frankly I find it ridiculous that there is no answer by Microsoft after 6 years, and even more ridiculous that such basic functionality is absent from Word templates in Dynamics 365. For Jove's sake, it was possible to do these things easily on the Psion 3mx organizer in 1995!
  • JohnKoso Profile Picture
    JohnKoso 5 on at
    RE: Conditional statement in CRM Word template based on field value

    Has anyone found an solution?

  • Jindrich Simacek Profile Picture
    Jindrich Simacek 25 on at
    RE: Conditional statement in CRM Word template based on field value

    Hi all,

    I'm having exactly the same problem. I'd need to display different String in the Word template based on an option set value.

    Was anyone able to successfully use an IF conditional statement in Dynamics Word Template?

    I've gone through the tutorial from Milan but I'm always getting the false value form this condition although it should return true.

    {IF <<payabledays>>="0" "Text1" "Text2 <<payabledays>>" \*MERGEFORMAT}

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Conditional statement in CRM Word template based on field value

    zzecevic and WNC_Paul,

    thanks for your replies.

    I noticed a few older answers on this forum where people wrote that it is not possible to use conditional statements in Word templates and that toggling visibility based on a field values is also a limitation.

    I was wondering if something in the meantime has changed.

    I found one great tutorial on how to use conditional text in word:

    support.clio.com/.../204459577-Tutorial-Using-Conditional-Text-in-Document-Automation

    Is it possible to achieve this with Dynamics CRM Word templates?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Conditional statement in CRM Word template based on field value

    I had a similar problem myself with our Word templates. We wanted large sections of text to either show or not show depending on values from the CRM fields, which also included other CRM field values.

    I didn't find a proper solution but got it working by creating extra hidden fields on the CRM form and using Javascript to fill those depending on the values I wanted for the template.

    It's probably a bad way to do it, but it is working for us and the Word template is looking how the people want it to.

  • zzecevic Profile Picture
    zzecevic on at
    RE: Conditional statement in CRM Word template based on field value

    Hi Milan, 

    I am having the same problem. I can get option set value if the field is outside conditional sentence, but in it I always get false value.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans