locked
Change custom activity behavior RRS feed

  • Question

  • Hi,

    To run the workflows from XAML I use WorkflowApplication.Run. I would like to change behavior of the custom activity depends on how the activity was running. I mean - in some situations my custom activity should report to DB, but in other situation shouldn't. I can add InArgument (or property) to this activity, but I don't know how to pass to my custom activity value for this InArgument (property).

    Is there any other way to do, what I described?

    Tuesday, September 21, 2010 11:43 AM

Answers

  • Hi,

    One way to do it would be to pass a value into your workflow via an inargument as it starts, and bind that to an inArgument on your custom activity. Then depending on the value, you would report to the DB or not in your activity. I can show some sample code of that if that's how you want to do it.

    Another way (since your main root activity may not have an argument that maps to this custom activity) is to use a workflow extension that is configured in your host. It can have a flag that says whether to write to the DB or not. Your custom activity can get this extension from the host, and inspect the value (or even use a default value if the extension is not configured)

    Here is an example of a workflow extension:

    http://blogs.msdn.com/b/tilovell/archive/2010/06/08/wf4-workflow-4-0-hosting-extensions.aspx

    Note that this example is about getting data out of a workflow and into the host, but you caan also examine properties of the extension from within the custom activity, so this might be a useful approach.

    Please let me know if either of these might work for you and let me know if you need more details.

    Thanks,

    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

     

    • Marked as answer by Divarius Wednesday, September 22, 2010 7:21 AM
    Tuesday, September 21, 2010 12:16 PM

All replies

  • Hi,

    One way to do it would be to pass a value into your workflow via an inargument as it starts, and bind that to an inArgument on your custom activity. Then depending on the value, you would report to the DB or not in your activity. I can show some sample code of that if that's how you want to do it.

    Another way (since your main root activity may not have an argument that maps to this custom activity) is to use a workflow extension that is configured in your host. It can have a flag that says whether to write to the DB or not. Your custom activity can get this extension from the host, and inspect the value (or even use a default value if the extension is not configured)

    Here is an example of a workflow extension:

    http://blogs.msdn.com/b/tilovell/archive/2010/06/08/wf4-workflow-4-0-hosting-extensions.aspx

    Note that this example is about getting data out of a workflow and into the host, but you caan also examine properties of the extension from within the custom activity, so this might be a useful approach.

    Please let me know if either of these might work for you and let me know if you need more details.

    Thanks,

    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

     

    • Marked as answer by Divarius Wednesday, September 22, 2010 7:21 AM
    Tuesday, September 21, 2010 12:16 PM
  • Hi Steve,

    Thank you for your answer. I decided to use extension and it works.

    Wednesday, September 22, 2010 7:21 AM