Tuesday, July 19, 2011

SharedVariables in CRM 2011 plugins

Hi All, There is a slight change in Shared Variables in CRM 2011.          

                // Passing Data to shared Variable
            context.SharedVariables.Add("PrimaryContact", (Object)contact.ToString());

            // Retrieving data from context shared variables.
                Guid contact = new Guid((string)context.SharedVariables["PrimaryContact"]);


  1. Hi Guru,

    Thanks for the post. I just want to have one information on the plugin part. Can we call a plugin inside a another plugin?


    1. Hi Megh,

      If you wants to call another plugin inside a plugin, you can perform the triggering action of the plugin to trigger. But it runs on the single transaction. if the plugin takes more time or fails entire transaction roll backs. Also it can lead to infinite loop.
      But you can't call directly a plugin inside the other except triggering the required action.


    2. Guru, your answer seems to be correct.

      Meg... i feel when you have something to be called from within the plug-in, why don't you write that code in plugin itself.
      Because when you know that the second plugin code needs to run on the fire of first plugin, it has to be on some trigger (create/update etc), if you are known to trigger, then why not to include the 2-plugin code in first one itself.

      Anyways... Meg, as far as i know, you don't look as a techie person. Perhaps you are you looking this for your team or for some freelancing work. you may contact me if you need some solution in this regards.