Archiv für den Monat: September 2009

Who triggered my plugin?

Do you ever want to know who triggered the execution of a plugin? This knowledge is handy, if you have to do some operation if the user entered data, but not if an external application made an update with the SDK.

The IPluginExecutionContext contains the property CallerOrigin which will tell us more about the origin which triggered the plugin execution.

The CallerOrigin is populated with one of these four types

  • Application – The user has triggered the event (by creating or editing a record).
  • AsyncService – The async service triggered the event (by workflow execution).
  • WebServiceApi – An application which makes use of the crm web service triggered the event.
  • OfflineOrigin – The event was triggered by replaying offline actions while going online.

This sample shows how to make use of this property (the sample is part of the sdk article Online vs. Offline Plug-ins)

using System;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;
 
public class OnlinePlugin : IPlugin
{
   public void Execute(IPluginExecutionContext context)
   {
      // Check to see if this is a playback context.
      CallerOrigin callerOrigin = context.CallerOrigin;
 
      if (callerOrigin is OfflineOrigin)
      {
         // This plug-in was fired from the playback queue after the user
         // selected to go online within Microsoft Dynamics CRM for Outlook.
         return;
      }
      else
      {
         // Do something here.
      }
   }
}

CRM log file locations

Every part of a Microsoft Dynamics CRM implementation produces some log output. In addition to the standard logging, you could enable tracing for nearly every CRM component for debugging purposes.

This post shows where you can find these log and trace files. For enabling the generation of trace files see http://support.microsoft.com/kb/907490. Please keep in mind that although the article says that you can configure the folder in which the trace files are generated via TraceDirectory, the location is hard coded in the applications. You can set a value, but it will be ignored.

Outlook Client

  • Standard log files %APPDATA%\Microsoft\MSCRM\Logs
  • Autoupdate log files %APPDATA%\Microsoft\MSCRM\AutoUpdate
  • Trace files %APPDATA%\Microsoft\MSCRM\Traces

Note: Since Update Rollup 7, these paths are switched to the %LOCALAPPDATA% folder in order to have a smaller roaming profile.

E-Mail Router

Data Migration Manager

  • Trace files %APPDATA%\Microsoft\MSCRM\Traces

CRM Server

  • Trace files {Install dir of application}\Trace
  • Setup log files, Deployment Manager, … %APPDATA%\Microsoft\MSCRM\Logs

Event log
In addition to the log files, there is also useful information in the application event log. With the installation of CRM you get following new event sources

  • MSCRMCallout
  • MSCRMDeletionService
  • MSCRMDeployment
  • MSCRMEmail
  • MSCRMKeyArchiveManager
  • MSCRMKeyGenerator
  • MSCRMKeyService
  • MSCRMLocatorService
  • MSCRMPerfCounters
  • MSCRMPlatform
  • MSCRMReporting
  • MSCRMTracing
  • MSCRMWebService

Update
Added note for Outlook Client log paths for version Rollup 7 or higher