Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

CRM Word Template conditional data

(0) ShareShare
ReportReport
Posted on by 140

Hello,

While working on word template on salesorder entity, I have below questions - 

1. I have address field to be populated on template. If address line 1 contains street number then I need to take only street number from Address Line 1 and put it in another column on word template. How can I achieve this?

2. How can I generate the date on which word template generated and post it in word template?

 

Thanks in advance.

  • Thenerdy Profile Picture
    Thenerdy 35 on at
    RE: CRM Word Template conditional data

    bare in mind with this product it uses FetchXml - and has a 50 attribute limit due to this. Whereas the native route doesn't appear to have an attribute limit.

  • Verified answer
    Wahaj Rashid Profile Picture
    Wahaj Rashid 11,321 on at
    RE: CRM Word Template conditional data

    Hi,

    You cannot do this using OOB World Templates.

    The idea is to have a separate (new) field and calculate its value based on the original field.

    For example:

    • Original Field
      • Name: Demo AAA (new_demoaaa)
      • Type: Single Text
    • New Field: Demo AAA Print (new_demoaaaprint)
    • Type: Single Text (Calculated)
    • Calculated Field Configuration:

    pastedimage1595856566380v1.png

    Here is the result on form:

    pastedimage1595856604346v2.png

    Now in the word template, use new field (Demo AAA Print) instead of original.

    This is just an example to give your idea, you might have to improvise this as per your need.

    Furthermore, Calculated Field Functions are limited, if you cannot use Calculated Field, you can create a Simple Single Line Text filed and implement your logic in following ways:

    • Microsoft Flow: create a flow to update new field's value as per your logic. However, this won't be real-time.
    • Plugin: update new fields value on CREATE/UPDATE step synchronously.
    • JavaScript: on-change of original field, set new field's value. However, this will only work if you update Original fields value on the form.

    Finally, if you have a lot of fields where you want to implement conditions in word template, and you want to reduce your effort, it might be a good idea to try/purchase Documents Core Pack by mscrm-addons:

    https://www.mscrm-addons.com/Products/DocumentsCorePack

    Here is a video, how it works:

    https://www.youtube.com/watch?v=dsqGbJ2kD3w

    This add-on allows you to add conditions in world template.

    Let me know, if you have further questions.

    Thanks,

    Wahaj

  • snehaln676 Profile Picture
    snehaln676 140 on at
    RE: CRM Word Template conditional data

    Hi Wahaj,

    Really appreciate you response for the Date part! Thank you.

    For 1st part of my query, I have a requirement like below -

    For example : I have a field named "new_customField" on template which contains the value "AAABBB".

    I want to check if this "new_customField" contains value "AAA" then I need to paste only "AAA" part of the string in another field on template.

    Is this possible with the Word Template? Can I achieve this without adding any new field in CRM?

  • Suggested answer
    Wahaj Rashid Profile Picture
    Wahaj Rashid 11,321 on at
    RE: CRM Word Template conditional data

    Hi,

    For the first question, as Lu recommended, you could create a custom field and a business rule to set it's value based on following condition:

    • If Address Street 1 contains data then set custom address field value to Address Street 1 value.
    • Else set custom address field value to Address Street 2 value.

    For date, you can add a placeholder for Current Date (or Date Time), here are the steps:

    • In word, place your marker where you want to put current date.
    • Then in the Insert tab, Text section click on Insert Date Time option.
    • Select the required format and re-upload the template.

    pastedimage1595843926799v1.png

    I found this interesting article to add conditions in CRM Word Templates, how ever I never tested it:

    https://crmtipoftheday.com/716/conditional-values-in-word-templates/

    Furthermore, it would be simple to use the above approach.

    Thanks,

    Wahaj

    (if it answers your query, mark it as verified)

  • snehaln676 Profile Picture
    snehaln676 140 on at
    RE: CRM Word Template conditional data

    Hello Hao,

    Thanks for your reply!

    However, is there any way to customize above conditions in template by adding macros or by adding any other condition? I am looking for a solution where I need not to add additional fields.

  • Suggested answer
    LuHao Profile Picture
    LuHao 40,876 on at
    RE: CRM Word Template conditional data

    Hi partner,

    Word Template itself has very little customizable content, so I would recommend that you customize the Order and then export it to Word Template.

    1. New a field to store the street number. Then new a business rule, condition is that the street fields of address line 1 contains data, action is that set the new field value to the street fields.

    In this way, before the Word Template is generated, the new field already has the street number, and set the new field as a column in the Word Template.

    2. New a calculated field to show today date.

    pastedimage1595843233926v3.png        pastedimage1595842849132v1.png

    Then add this field to the Word Template, this calculated field is the date on which word template generated.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans