locked
How to access a Code Activity of a Composite Activity RRS feed

  • Question

  • In our workflows, we often handle tasks the same way using the following four steps:

    1. createTask activity
    2. whileTaskNotComplete activity
    3. completeTask activity
    4. logToHistoryList activity

    To make things easier, we combined these four tasks into a single composite activity so that we could just drop the composite activity into our workflow whenever we want to create a task instead of building the four steps from scratch each time.

     

    What I want to do now is add a code activity called codeActivity_Init() as the first step of the composite activity so that I can do initialization of variables and run any other initialization code that is necessary for each task. The codeActivity_Init() is just a placeholder in the composite activity...it doesn't contain any code. When I instantiate the composite activity by dropping it into my workflow, then I want to fill in the codeActivity_Init() with the relevant initialization code for each particular task I'm creating.

     

    How do I override the default/empty codeActivity_Init() from the composite activity to add my specific code for each instance that I drop onto my workflow?

     

    Thanks,

    Scott

    Friday, June 8, 2007 3:27 PM

Answers

  • Figured this out...the solution is to use the "Promote Bindable Properties" command on the composite activity. Then when we drop the composite activity into our workflows, the internal codeActivity_Init() method is exposed as a settable parameter of the composite activity...this allows us to set the codeActivity_Init() method of the composite activity to point to the custom method we write in our workflow.
    Monday, June 18, 2007 3:42 PM

All replies

  • Figured this out...the solution is to use the "Promote Bindable Properties" command on the composite activity. Then when we drop the composite activity into our workflows, the internal codeActivity_Init() method is exposed as a settable parameter of the composite activity...this allows us to set the codeActivity_Init() method of the composite activity to point to the custom method we write in our workflow.
    Monday, June 18, 2007 3:42 PM
  • A nicer way might be to use a eventhandler as a dependencyproperty  and expose your own Before-event in your own custom activity

     

    (I'm using almost the same approach in my projects)

     

    Best of luck!

    Tuesday, June 19, 2007 6:01 AM