Search code examples
dynamics-crm-2011dynamics-crm

Dynamics CRM 2011 plugin in outlook only?


We need to restrict some delete operations done automatically from Outlook towards CRM 2011 while we wait for a bug fix in a 3rd party addin. Is it possible to have a plugin in Dynamics CRM 2011 on-premise that either only executes for the Outlook client (offline not in use) or that checks in the execution if the plugin is triggered from Outlook?

In CRM 4.0 there used to be a CallerOrigin property that gave at least some information on this, but that property is now seemingly only internal in the CRM 2011 model.


Solution

  • I accessed CallerOrigin by reflection (it is still there, but not exposed in the SDK libraries).

    The code below is a short version of my code, without any validations or null checks (i.e. not production code) just to show how it works in a few lines:

    object callerOrigin = context.GetType().GetProperty("CallerOrigin").GetValue(context, null);
    
    return callerorigin.GetType().Name; // will return "WebServiceApiOrigin" if called from outlook or web services