Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

How to get the Email id in a pre (or post) create Case (aka Incident) plugin

$
0
0

The goal here is to get the received date of an email. This email will be converted to an case, and the received date will be displayed in the case form as a field.

When an email is converted to a case (aka incident), from a email web form, a pre create plugin is triggered on my platform. This plugin is synchronous and sandboxed.

I would like to retrieve the id of this converted email in my plugin so I can retrieve information about it and put some of it in my case.

So far I tried to retrieve it like that:

using (var entityContext = new EntityContext(localContext.OrganizationService))
{
    var sourceEmail = entityContext.EmailSet.FirstOrDefault((email) => email.Incident_Emails.Id == incident.Id);
    if (sourceEmail != null)
    {
        var emailDate = sourceEmail.ActualEnd;
    }
}

But it sourceMail is null.

If I switch the plugin mode to async, the sourceMail is ok. Unfortunately, this is not an acceptable solution because the case form will be shown to the user before the plugin has ran, and so the received email date will be empty.


Viewing all articles
Browse latest Browse all 8223

Trending Articles