1
votes

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.

2
Are these operations done during synchronisation from Outlook to CRM, or using CRM forms from within the CRM section inside Outlook?AdamV
As long as you aren't offline or syncing after being offline, there is no notion of "Outlook" context. All actions are server side.ccellar
@AdamV Synchronization, so not the forms.krembanan
@ccellar You are correct, luckily we have no other apps deleting emails over web services, so we were able to use indications of "web service" context instead of just Outlook. See my answer below.krembanan

2 Answers

3
votes

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
0
votes

There are two properties on the IExecutionContext that you should be aware of when writing plugins to run offline in Outlook:

IExecutionContext.IsExecutingOffline indicates whether the plugin is running in Outlook while offline, and:

IExecutionContext.IsOfflinePlayback indicates that the plugin is being fired when changes made whilst Outlook client was offline are being played back when the client connects to the server again and sync the changes with the server.