Enabling Mail Merge Template for other System entities


Hi,

We had a requirement to use the exiting templates for salesorder entity. However as we know, we only get the option of Lead, Opportunity, Contact , Account , Quote and other custom entities in Associated Entity drop down for the mail merge template.

So i first tried out this, exported the customization for the salesorder entity and added attribute IsMailMergeEnabled with the value of 1, imported it and published it.

However this didn’t work, it only works for custom entities.

Than i tried to do the same using the Metadata Service.

// Initialize MetadataService
MetadataService mdService = new MetadataService();
mdService.Credentials = System.Net.CredentialCache.DefaultCredentials;
mdService.CrmAuthenticationTokenValue = new CrmAuthenticationToken();
mdService.CrmAuthenticationTokenValue.AuthenticationType = 0;
mdService.CrmAuthenticationTokenValue.OrganizationName = "orgname";

// Use RetrieveEntityRequest to get the metadataid for the sales order entity
RetrieveEntityRequest entityMDRequest = new RetrieveEntityRequest();
entityMDRequest.LogicalName = "salesorder";
entityMDRequest.EntityItems = EntityItems.EntityOnly;
RetrieveEntityResponse entityMDResponse1 = (RetrieveEntityResponse)mdService.Execute(entityMDRequest);

// Initialize EntityMetadata for the salesorder entity
EntityMetadata entityMD = new EntityMetadata();
entityMD.MetadataId = entityMDResponse1.EntityMetadata.MetadataId;
// Set IsMailMergeEnabled to true
entityMD.IsMailMergeEnabled = new CrmBoolean();
entityMD.IsMailMergeEnabled.Value = true;

// Use UpdateEntityRequest to update the metadata for sales order entity
UpdateEntityRequest ueRequest = new UpdateEntityRequest();
ueRequest.Entity = entityMD;
UpdateEntityResponse ueResponse = (UpdateEntityResponse)mdService.Execute(ueRequest);

However it gave the following error

"<error>\n  <code>0x80040203</code>\n  <description>Entity 38ded7b5-9ec6-4e77-919a-c408023a4db4 is not a custom entity and therefore cannot have its mail merge enabled properties changed</description>\n  <type>Platform</type>\n</error>"

Finally then i tried out this,

Updated the value for IsMailMergeEnabled in the organization database itself.

This is the sql query for that

update MetadataSchema.Entity
set ismailmergeenabled=1
where name=’salesorder’

Followed by an IISReset.

And it worked !!!!  ( however it is unsupported !!! )

I was able to see the order entity in the Associated Entity drop down for the mail merge template.

I am yet to test it thoroughly though !

Check out this post as well

https://nishantrana.wordpress.com/2009/10/07/using-mail-merge-for-other-entities-in-crm-4/

Bye..


Discover more from Nishant Rana's Weblog

Subscribe to get the latest posts sent to your email.

Unknown's avatar

Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

6 thoughts on “Enabling Mail Merge Template for other System entities”

  1. Nishant,
    Thank you so much for this unsupported customisation trick. I have been searching the net for a long time for this, and the database hack followed by iisreset saved us from a lot of hassles.

    Thank you for posting this.

    Like

  2. I have done this and it worked great, but everytime i come back it is missing from the list even though the value is still set to 1 in the database.

    Like

  3. I run the script, reset IIS but I can´t see Order entity in the templates list. This solution also is valid using rollup 10?

    Like

  4. Hi.
    Has anyone ever succeeded with making the MailMerge button/function work on the FORM? I can make it work on the GRID, but not the form. Need help…

    Like

Leave a reply to Fer Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Nishant Rana's Weblog

Subscribe now to keep reading and get access to the full archive.

Continue reading

Power Platform Puzzles

D365 CRM, Power Platform Tips &Tricks

Power Spark

Power Spark By Shrangarika

Van Carl Nguyen

Exploration of Power Platform

My Trial

It is my experience timeline.

Power⚡Thomas

Sharing my knowledge and experience about the Microsoft Power Platform.

Arpit Power Guide

a guide to powering up community

Welcome to the Blog of Paul Andrew

Sponsored by Cloud Formations Ltd

Deriving Dynamics 365

Deriving Solutions and features on Power Platform/Dynamics 365

The CRM Ninja

Thoughts & musings from a Microsoft Business Applications Ninja!

D CRM Explorer

Learn about Microsoft Dynamics CRM Power Platform customization and implementation and other cool stuffs

Stroke // Jonas Rapp

I know pre-stroke. I will improve who I was.

Power Melange

Power Melange By Shalinee

Clavin's Blog - PPUG.ORG

AI - Power Automate - Power Apps - SharePoint Online - Azure - Nintex - K2 - Artificial Intelligence

Sat Sangha Salon

An Inquiry in Being

The Indoencers

The Influencers & Influences of Indian Music

Monika Halan's blog

Hand's-free money management

D365 Demystified

A closer look at Microsoft Dynamics 365.

Microsoft Mate (msftmate) - Andrew Rogers

Experienced consultant primarily focused on Microsoft Dynamics 365 and the Power Platform

Manmit Rahevar's Blog

One Stop Destination for Microsoft Technology Solutions

MG

Naturally Curious

Brian Illand

Power Platform and Dynamics 365

Steve Mordue

The Professional Paraphraser

Subwoofer 101

Bass defines your home theater

SQLTwins by Nakul Vachhrajani

SQL Server tips and experiences dedicated to my twin daughters.

Everything D365

Discovering Azure DevOps and D365 Business Applications

Tech Wizard

Lets do IT Spells

XRM Tricks (Power Platform & Dynamics CRM )

Power Platform & Dynamics CRM

CRM TIPS BY PRM

Mail to crmtipsbyprm@gmail.com for queries and suggestions

nijos.dev

Giving back to the community what I have learned

Power Platform Learning

Your Go-To Resource for Power Apps, Power Automate & More

xrm CRM Dynamics

Dynamics CRM Technical & Functional Info

Dynamics 365 Blogs - Explained in unique way

Sometimes you need to look at things from different perspective.