Home

Dec 1, 2010

Mail Merge functionality in CRM 2011

In CRM 4.0, merge functionality was out of the box for few system entity. There was no supported way to remove it or to enable it for any entities.

CRM 2011, you can enable mail merge for any entity by checking the Mail Merge checkbox from entity setting page. refer below image for more details.

You can update also update it programmatically using below code snippets :

RetrieveEntityRequest retrieveBankAccountEntityRequest = new RetrieveEntityRequest
{
EntityFilters = EntityFilters.Entity,
LogicalName = "account"
};
RetrieveEntityResponse retrieveBankAccountEntityResponse = (RetrieveEntityResponse)_serviceProxy.Execute(retrieveBankAccountEntityRequest);
EntityMetadata BankAccountEntity = retrieveBankAccountEntityResponse.EntityMetadata;

// Disable Mail merge
BankAccountEntity.IsMailMergeEnabled = new BooleanManagedProperty(false);
UpdateEntityRequest updateBankAccountRequest = new UpdateEntityRequest
{
Entity = BankAccountEntity,
};
_serviceProxy.Execute(updateBankAccountRequest);

Refer this link for more details -


http://msdn.microsoft.com/en-us/library/gg509032.aspx

Mail Merge

4 comments:

Carrie said...

what if the mail merge checkbox is disabled?

laris said...

for orders and invoices this option is greyed out. How can this be enabled for these crucial entities? Thx

Amol Gholap said...

// use this code to enable it
RetrieveEntityRequest retrieveBankAccountEntityRequest = new RetrieveEntityRequest
{
EntityFilters = EntityFilters.Entity,
LogicalName = "account"
};
RetrieveEntityResponse retrieveBankAccountEntityResponse = (RetrieveEntityResponse)_serviceProxy.Execute(retrieveBankAccountEntityRequest);
EntityMetadata BankAccountEntity = retrieveBankAccountEntityResponse.EntityMetadata;

// Disable Mail merge
BankAccountEntity.IsMailMergeEnabled = new BooleanManagedProperty(true);
UpdateEntityRequest updateBankAccountRequest = new UpdateEntityRequest
{
Entity = BankAccountEntity,
};
_serviceProxy.Execute(updateBankAccountRequest);

Tully said...

Using this code, I have tried to enable Mail Merge for the quote entity, but when doing so I get the error "Entity {GUID} is not a custom entity and therefore cannot have its mail merge enabled properties changed" - that being said, a direct SQL update works fine:

UPDATE MetadataSchema.Entity SET IsMailMergeEnabled=1 WHERE Name='quote'

This code works for custom entities, but the CRM platform validation rejects it for any system entities.

It's a pity Microsoft adds these artificial limitations into CRM.