locked
register crm plugin only for Outlook client RRS feed

  • Question


  • Help needed to find the client(IE or Outlook) from which the user is accessing the CRM in a plugin which is registered on retrievemultiple of Savedquery. 

    or 

    Is there any way to register CRM 2013 plugin only for outlook client (online mode)? 


    Thursday, June 5, 2014 4:45 PM

All replies

  • try below code:- object callerOrigin = context.GetType().GetProperty("CallerOrigin").GetValue(context, null); return callerorigin.GetType().Name; // will return "WebServiceApiOrigin" if called from outlook

    Regards Faisal

    Friday, June 6, 2014 12:45 PM
  • Another code from sdk:-

    // Determine if the Outlook client is running
    if (outlookService.IsCrmClientLoaded)
    {
        if (outlookService.IsCrmDesktopClient)
        {
            // The desktop client cannot go offline
            Console.WriteLine("CRM Client Desktop URL: " +
                outlookService.ServerUri.AbsoluteUri);
            Console.WriteLine("CRM Client state: " +
                outlookService.State.ToString());
        }
        else
        {
            // See if laptop client is offline
            if (outlookService.IsCrmClientOffline)
            {
                Console.WriteLine("CRM Client Offline URL: " +
                    outlookService.ServerUri.AbsoluteUri);
                Console.WriteLine("CRM Client state: " +
                    outlookService.State.ToString());

                // Take client online
                // NOTE: GoOnline() will automatically Sync up with CRM
                // database, no need to call Sync() manually
                Console.WriteLine("Going Online...");
                outlookService.GoOnline();

                Console.WriteLine("CRM Client state: " +
                    outlookService.State.ToString());
            }
            else
            {
                Console.WriteLine("CRM Client Online URL: " +
                    outlookService.ServerUri.AbsoluteUri);
                Console.WriteLine("CRM Client state: " +
                    outlookService.State.ToString());

                // Take client offline
                // NOTE: GoOffline triggers a synchronization of the
                // offline database with the online server.
                // If a sync is not required, you can use SetOffline().
                Console.WriteLine("Going Offline...");
                outlookService.GoOffline();

                Console.WriteLine("CRM Client state: " +
                    outlookService.State.ToString());
            }
        }
    }


    Regards Faisal

    Friday, June 6, 2014 1:47 PM
  • Unfortunately there are problems with both suggested solutions above:

    • CallerOrigin has not been supported after CRM 4. It might work, but I wouldn't want to rely on it
    • The outlookService class is (I think) only available within Outlook, and not within a plugin

    I don't think there is a supported way to determine within a plugin what client a call from


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Friday, June 6, 2014 8:43 PM
    Moderator