Search code examples
c#pluginsoutlookdynamics-crmdynamics-crm-2015

Recognize record created from outlook/email in plugin


I'd like to perform some operation in mscrm plugin, if a new record is created automatically by CRM client for Outlook. Eg. it can be a contact or an incident created from an email.

Is there way to check this condition?


We have contact's first name and last name filled oppositely and incident without the caseorigincode field filled, when created from an email in Outlook. Maybe there is a better workarround to solve these two issues. But still I am wondering about the original question.


Solution

  • According to the sources available online, there is really no reliable way to solve this.

    There was property CallerOrigin until CRM 4. Then it got deprecated, but continued working for some time, as state in another answer (https://stackoverflow.com/a/14812885/1474519). But it doesn’t seem to be working anymore in CRM 2015.

    I found couple advices with IsExecutingOffline and IsOfflinePlayback, but it is really not solving the problem.

    I also found a tip to check this code HttpContext.Current.Request.Url.ToString();. This doesn’t work for me.

    I found the most complete information here: http://blog.simpletrees.com/2012/03/executioncontextcallerorigin-in.html According to this article, I am sending a value in a hidden field from my form (or thru API, from plugin, from workflow). As this field is not set when a record is created from outlook, I can recognize the record being created from Outlook. There is of course problem, this field might not be set when importing records or when using mobile app. But I don’t see a better way to go.

    Therefore, I started request on Microsoft Connect to add this functionality. You can vote for it here: https://connect.microsoft.com/dynamicssuggestions/feedback/details/1776771