Robert Pröll

.NET Software Architect

Key areas of interest: ALM, .NET C#, PowerShell, Azure, Dynamics 365 Tooling

Robert started in the area of ASP.NET projects and has now more than 10 years of experience in the international Dynamics Enterprise business.

He works mainly as a principal software architect at Kupp and as an external consultant for Microsoft.

Robert Pröll

.NET Software Architect

How to handle different entity type codes for custom entities

Deploy Dynamics365 Document Templates (Word & Excel)

Posted: 04.2019 | Category: DataTransfer

Robert Pröll | .NET Software Architect


The default template functionality for word and excel documents uses entity type codes (etc) instead of logical names for entity and attributes.

This causes import issues due to the fact that etc‘s might be different on each environment.
(for custom entities, values start at 10.000)


Identify the issue:

Documents with an invalid etc can be imported but the field Entity Type Code would be empty, which means it cannot be used.

How to solve it: 

The solution is pretty simple if we know the entity type codes for both systems (otherwise it can be retrieved via the Metadata Service (SDK)):

  1. Rename and extract the document file (e.g. Overview.docx =>
  2. Open the directory (The picture shows a subdirectory)
  3. Then all occurrences of the old etc must be replaced. There are some ways to solve that. A quick search and replace with a pattern like ([LogicalName]/[ETC]) works in most cases but is risky. A clean regex and validation is a better solution.

    It’s important to apply the change to all documents within the zip:
  4. Afterwards zip the files again and rename it back to the previous extensions. E.g. => docx
  5. Upload the document to crm. Double check if the etc is correctly set in crm.


This approach works well but is time consuming and not really a funny task. Our recommended solution is to do that automatically with KDTooling Deployment Manager.