Hi,
I am getting a strange error when trying to execute an InstantiateTemplateRequest SDK message inside a plugin.
The call is fairly simple and you expect the Response to contain the e-mail activity created with that template.
InstantiateTemplateRequest instTemplate = new InstantiateTemplateRequest();
instTemplate.TemplateId = templatedId;
instTemplate.ObjectId = relatedtoEntityRef.Id;
instTemplate.ObjectType = relatedtoEntityRef.LogicalName;
InstantiateTemplateResponse instTemplateResponse = (InstantiateTemplateResponse)service.Execute(instTemplate);
When calling the service.Execute() an exception is thrown by CRM.
The root error seems to be:
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Crm.ObjectModel.TemplateXmlCreatorContact.GetContactXmlAndAddress()
If I try to manually create an e-mail activity through the front-end, I also get a similar error.
Interestingly, it only seems to occur for certain contacts (as others work ok).
This would point to it being data related but I have no idea what could cause this kind of failure.
Has anyone else ever seen this before?
I can post/provide the server trace logs if needed.
Regards,
Shaun Harvey
*This post is locked for comments