locked
Is it possible to register a plug-in with multiple entities in a single step? RRS feed

  • Question

  • I am working on CRM 4.0 and I am creating a custom data syncing application.  I am using a plug-in to collect Create, Update and Delete events on my custom entities and save the information to an xml file.  Everything is working fine, but I have to create 3 steps (Create, Update, Delete) per custom entity.  Is there a way to register the plug-in to multiple MessageNames in a single step?  Also is there a way to register the plug-in to multiple entities in a single step?
    Thursday, May 7, 2009 7:34 PM

Answers

  • Hi Timothy,

    There's no way to do this with the PluginRegistrationTool, but I've solved the problem by creating a custom attribute (C# one that is) called InstallStepAttribute which takes the required parameters for a plugin step. I then decorate my plugin with the attributes like this:

    [InstallStep("Create", "Account", Stage = Pre)]
    [InstallStep("Update", "Account", Stage = Pre)]
    [InstallStep("Delete", "Account", Stage = Pre)]
    public class MyPlugin : IPlugin
    {
         ....
    }

    In the plugin i then have a class which inherits from the System.Configuration.Install.Installer, this will perform the actual installation of the plugins. This is done with a RegisterSolutionRequest.

    Having this I can install my plugins with a cmd-file having content like this:
    "C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe" /url=http://localhost:5555/mscrmservices/2007/crmservice.asmx /username=me /password=mypass /domain=dom "NameOfMyPlugin.dll"

    and uninstall them like this:
    "C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe" /u /url=http://localhost:5555/mscrmservices/2007/crmservice.asmx /username=me /password=mypass /domain=dom "NameOfMyPlugin.dll"



    • Edited by IAmNotDrunk Friday, May 8, 2009 12:40 AM ?
    • Marked as answer by Timothy Hays Friday, May 15, 2009 1:30 PM
    Friday, May 8, 2009 12:39 AM
  • Hi,

    If you look at the Programming Microsoft Dynamics CRM 4.0 book, there something called PluginStepAttributes and a deployment code. By using this you can add many steps in the sourcecode and in my view it is easy to maintain while development. use the deploymentcode the deploy/register.

    thanks
    Tom
    Friday, May 8, 2009 3:05 AM

All replies

  • Hi, Timothy.

    It seems that there no posibility to register multiple entities to one step or multiple messages to one step.
    On the other hand you can create big plugin which will handle all messages for all required entities and you will have to register this Plugin multiple time fore each pair entity|message.

    Истина открывается подготовленному уму. Мой блог - http://a33ik.blogspot.com
    Thursday, May 7, 2009 7:39 PM
    Moderator
  • Hi Timothy,

    There's no way to do this with the PluginRegistrationTool, but I've solved the problem by creating a custom attribute (C# one that is) called InstallStepAttribute which takes the required parameters for a plugin step. I then decorate my plugin with the attributes like this:

    [InstallStep("Create", "Account", Stage = Pre)]
    [InstallStep("Update", "Account", Stage = Pre)]
    [InstallStep("Delete", "Account", Stage = Pre)]
    public class MyPlugin : IPlugin
    {
         ....
    }

    In the plugin i then have a class which inherits from the System.Configuration.Install.Installer, this will perform the actual installation of the plugins. This is done with a RegisterSolutionRequest.

    Having this I can install my plugins with a cmd-file having content like this:
    "C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe" /url=http://localhost:5555/mscrmservices/2007/crmservice.asmx /username=me /password=mypass /domain=dom "NameOfMyPlugin.dll"

    and uninstall them like this:
    "C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe" /u /url=http://localhost:5555/mscrmservices/2007/crmservice.asmx /username=me /password=mypass /domain=dom "NameOfMyPlugin.dll"



    • Edited by IAmNotDrunk Friday, May 8, 2009 12:40 AM ?
    • Marked as answer by Timothy Hays Friday, May 15, 2009 1:30 PM
    Friday, May 8, 2009 12:39 AM
  • Hi,

    If you look at the Programming Microsoft Dynamics CRM 4.0 book, there something called PluginStepAttributes and a deployment code. By using this you can add many steps in the sourcecode and in my view it is easy to maintain while development. use the deploymentcode the deploy/register.

    thanks
    Tom
    Friday, May 8, 2009 3:05 AM
  • Other than registering one message/entity combination per step, the Plug-in Registration tool supports registering a plug-in on one message for all supported entities. You can do that by not specifying an entitiy in the Primary entity field.

    PeterH
    Friday, May 8, 2009 9:36 PM
  • There is an option in plugin registration tool....just dont give any prymary entity name or secondary entity name while registering step, This will make plugin steps to get executed for any entity  updation ,deletion ,creation.

    Thanks Regards Prashanth Kamasamudram Even the least work done for others awakens the power within; even thinking the least good of others gradually instills into the heart the strength of a lion.

    Friday, September 6, 2013 10:46 AM