locked
shared variables clearing down between calls RRS feed

  • Question

  • Hi,

    I am using CRM 2013 RU2. In our plugin code, I am adding a context shared variable. Debugging it adds the value to the shared variables and I can see it in the collection. However when a subsequent plugin executes all the shared variables are gone. :-(

    I have checked parent context as well and there is no sign of it, I've tried adding it to parent context but it never exists in my plugin stage.

    I've tried both sanboxed and not sandboxed.

    Any ideas anyone?

    Here is my add code...

             context.SharedVariables.Add(new KeyValuePair<string, object>("bypassReadAuditing", new object()));

    and my code to check if the key exists (though there are never any keys to retrieve)

    if (context.SharedVariables.ContainsKey("bypassReadAuditing"))

    Regards

    Chris

    Thursday, June 19, 2014 6:04 PM

All replies

  • Hi,

    I believe both your Plugins are registered on the same entity and the stage where you're adding the Shared Variable is earlier than the stage where you're trying to read it back?

    Also, while reading, have you tried reading from the ParentContext? This might be helpful.


    Admin QuikView Solution for CRM 2013

    Thursday, June 19, 2014 6:17 PM
  • I've looked in to all that,

    however i believe it is down to the fact that we are writing the shared variable in an update message and trying to read it in a retrieve method and they don't share the same shared variables :-(

    basically we are trying to prevent a retrieve plugin from firing if the cause of the retrieve was a refresh after a save.

    Chris 

    Thursday, June 19, 2014 9:02 PM
  • Hi Chris,

    The scenario you state wouldn't facilitate the use of shared variables because they are registered on different messages one being update and the other being retrieve.


    Admin QuikView Solution for CRM 2013

    Friday, June 20, 2014 4:31 AM