CRM Software Logo

Microsoft Dynamics 365 & Dynamics CRM experts provide reviews and opinions to aid professionals with the Dynamics 365 selection process.

 
 
Dianna Davis - Dynamics Objects

Hide / Display Text in CRM “Word Templates”

Email | Print

Hide / Display text in CRM “Word Templates”

Microsoft introduced the CRM Word Templates feature, in Dynamics CRM version 2016. Using Word Templates, users can insert fields from CRM records in a Word document. The feature stops here.
With Dynamics PDF-Docs (click here to download trial version) users can, in one click, PDF the generated Word Document, attach it to Notes, Email or upload the document to SharePoint location or add documents from SharePoint as attachments to Email workflow, together with the PDF generated with Word Template.

What if you need these features, not available with CRM "Word Templates"?

  1. Keeping rich text formatted fields in CRM, after they are inserted to the document. In current version of Word Templates, formatting is lost in the document, and comes up as one long line of text.
  2. Your document requires logical operations like hide or display text based on the content of a field in CRM record. As an example, you wish to hide / Display the table header “Discount” for invoices, quotes and similar documents, generated for clients not entitled for discount.

OR you need the feature of inserting fields from CRM records into Word document, and the CRM version installed on your server is previous to 2016 release?

Well before Microsoft released version 2016, Dynamics Objects developed “Dynamics Docs” to perform these much needed functionalities, for all CRM versions. (Dynamics Docs, can be downloaded here).

Same as with Dynamics PDF-Docs, with one click you can PDF the generated documents, attach the PDF file to Notes, Email and upload the document to SharePoint or attach documents from SharePoint to Email workflow

Returning to our topic, the issue with Rich Text was explained and resolved in previous  post:

http://www.crmsoftwareblog.com/2017/06/rich-text-word-templates-issue-resolved-dynamics-docs/

In this post I will show how text can be hidden or displayed, based on selected option in the CRM record. Consider a letter, sent from the local library, which only one of the 2 below, mutually exclusive lines (in bold letters), can be displayed:
======================================================

Dear <<ClientName>>

Thank you for your Email received yesterday.

I wish to confirm the following:

Your current borrowing entitlements are <<books>> books per month

Your video entitlements are <<video>> per year

If the above is incorrect, don’t hesitate contacting me

=======================================================

Words between << and >> symbols, are placeholders and are automatically replaced with the field content they are linked to. We wish to display one of the above lines, based on the selected option either Books or Videos of the Type field of the entity.

First step is to create the document text as variable, by making it a placeholder. As spaces are not allowed in placeholder, and still keep the variable name easily recognized, we use exact same text, but without spaces:

<<Yourcurrentborrowingentitlementsare>> <<books>> <<bookspermonth>>

<<Yourvideoentitlementsare>> <<video>> <<per year>>

 

After importing the Word document with all variables set as placeholders, click the Add Fields to Template. In this example we demonstrate the hide/ display of the first line, the second line setting is very similar to the first one.

Select the Merge Tag:  <<Yourcurrentborrowingentitlementsare>> the related entity is Library and the condition is on the option selected in the Type attribute.

Insert Expression. If Books=Books then the Special Text = Your current borrowing entitlements are

Otherwise = blank

 

 

Similar condition applies to the placeholder <<bookspermonth>>

Select the Merge Tag:  <<bookspermonth>> the related entity is Library and the condition is on the option selected in the Type attribute.

Insert Expression. If Books=Books then the Special Text = books per month

Otherwise = blank

 

 

Don’t forget that the <<books>> placeholder is a number and you need to add condition to hide it as well. The expression is:

If Type=books then Books (the attribute Books of the entity) Otherwise=Blank

 

 

Click to download Dynamics Docs Trial Version

 

 

 

Ask This Expert a Question / Leave a Comment

 

 
 
Show Buttons
Hide Buttons