Hello - I'm creating a new case based on an email that's received in my CRM system. After I create the case, I want to associate the email with it, since that is the email from which the case was initiated. I thought the following code would work but it returns an "unknown error":
email.RegardingObjectId = new EntityReference(Incident.EntityLogicalName, caseId);
service.Associate(Incident.EntityLogicalName, caseId, new Relationship("Incident_Emails"),
new EntityReferenceCollection { new EntityReference(Email.EntityLogicalName, email.Id) });
What's missing here? I looked at the entity relationships in customization and it shows a parental relationship between incident and email on "regarding" so I set the email RegardingObjectId property to the ID of the case that I created earier in the method before calling Associate.
Any idea what might be causing this error? Am I not setting something correctly or simply not using the correct approach?