Getting/Settings dependency property values on a running workflow instance RRS feed

  • Question

  • I have a workflow that is hosted as a WCF service in IIS.  I need to change the value of a dependency property on some running instances of this workflow.  I created a new project and in that project I initialize a new instance of WorkflowRuntime and connect it to the same SQL persisteance store that my WCF service is hooked up to.  I called GetWorkflow and passed in the workflow instance ID and then called GetWorkflowDefinition to get the root activity.  I created a new WorkflowChanges class passing it my root activity.  When I examine the workflow activity instance, I do not see a value set for my dependency properties (they show null) but I can tell from the workflow behavior that the values must be set.  I tried setting the values in the TransientWorkflow instance with the SetValue method to the new value that I wanted.  Everything looks fine in the object and I called ApplyWorkflowChanges passing in my change class on the workflow instance.  I didn't get any errors but it didn't seem to change the value of the property on the running instance.  When I call back through to get the instance again after saving my changes everything shows null still.  What do I need to do to be able to see and change the values of the dependency properties on running workflow instances?
    Thursday, November 15, 2012 8:55 PM

All replies

  • Hello HeatherB.rsa,

    Thank you for your question.

    I am trying to involve someone familiar with this topic to further look at this issue.

    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, November 20, 2012 3:30 AM
  • Has there been any progress on this?
    Thursday, November 29, 2012 4:05 PM
  • From http://msdn.microsoft.com/en-us/library/ms734569(v=vs.85).aspx setting properties on transient workflow activities works as follows:
    For metadata properties, the values set on a transient workflow are effective on the running workflow, after the update is applied.
    For instance properties, the values set on a transient workflow are lost, after the update is applied. The original running workflow values are preserved.

    From http://msdn.microsoft.com/en-us/library/ms734775%28v=VS.85%29.aspx you can not modify property values in a running instance of a workflow using WorkflowChanges.

    As a workaround, in order to modify a property value (including a dependency property) you will need to construct a new activity to replace the existing activity. You should be able to access dependency properties when constructing the new activity.

    Wednesday, December 5, 2012 12:58 PM
  • So am I approaching this the wrong way?  Is there not a simple way to change a property on the workflow instance?  Could I deserialize the persisted workflow in some way, change it, and serialize it back to the database if I stopped the workflow host?  How about reading the property values out of a workflow instance?  As I stated, when I connected all of the properties values showed null even though I know they are set.  Is there a way I can read those out so I could at least get the information out of the workflows?
    Friday, December 7, 2012 7:25 PM