locked
Persisting Variables in WF4 RRS feed

  • Question

  • Hi,

     I have a xaml file in which there is a Sequence activity and 5 variables(all Boolean type having default values of false) are associated with that Sequence activity.After first run of the workflow I set 3 variables to true and I want these values to be stored when the workflow is persisted so that on reload of the workflow I can do something based on the true values of these variables.How to persist variables in WF4?

    Regards,

    Sandip

    • Changed type LeoTang Monday, June 4, 2012 1:19 AM
    Wednesday, May 30, 2012 1:57 PM

Answers

  • Hi,

    When you will reload the workflow it will automatically give you updated vales saved in last persisted state of the workflow.

    You dont  need to do some coding to acheive this.

    Thanks,

    Madhur 


    MB

    • Marked as answer by LeoTang Thursday, June 7, 2012 1:48 AM
    Thursday, May 31, 2012 5:59 AM

All replies

  • You can create an exetension deriving from PersistenceParticipant class and override the CollectValues() and PublishValues() to retain the values in Persistence store.

    Wednesday, May 30, 2012 4:09 PM
  • Hi,

    When you run the workflow and change the values of the variables within the workflow, the values of these variables will be persisted automatically with the workflow, and when it is reloaded, the new values will be loaded along with the workflow. Subsequent activities in the workflow that use these variables will use the new values that were set before the workflow persisted. Do you need to do something extra with these varialbes outside the workflow, or do you need to make sure that when the workflow reloads you don't get the default values?

    Steve Danielson [Microsoft]
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

    Wednesday, May 30, 2012 7:11 PM
  • Hi,

    Steve -> I need to make sure that when the workflow reloads I don't get the default values of the variables.

    Leo -> In case of CollectValues() and PublishValues() how do I get and set the values of the variables without having an ActivityContext object?

    Regards,

    Sandip

    Thursday, May 31, 2012 5:47 AM
  • Hi,

    When you will reload the workflow it will automatically give you updated vales saved in last persisted state of the workflow.

    You dont  need to do some coding to acheive this.

    Thanks,

    Madhur 


    MB

    • Marked as answer by LeoTang Thursday, June 7, 2012 1:48 AM
    Thursday, May 31, 2012 5:59 AM