How to access properties of the last used activity in a workflow

Hi,

i'm new in developing workflows/activitys and i have one question. I have developed one new activity with one specific public property (for expample "TestProperty")! Then i have a second new activity and within the Execute function of this activity i wan't to check if the last used activity in the current workflow is a type of my first new activity. If this is the case, i wan't to access the public property ("TestProperty") from the first new activity within my second activity. Is this possible, and if yes, how can i realize that

I'm using the Beta2 (January release) of the SDK.

Regards,
Thomas



Answer this question

How to access properties of the last used activity in a workflow

  • sinisterguy

    Thomas,
    If I understand your correctly, you "want" to be able to view the public properties from another activity, inside your working activity, if the workflow "type" is the same. is this correct I'm not sure what you mean by "type".

    Bill



  • KirankumarC

    "It might be as easy as having a property on your "accessing" activity that stores the value you want from the "target" activity and then binding (using ActivityBind class) the accessing activity's property to the target activity's property. From the execute method of the accessing activity, you can access the value you need by just getting your own property!"

    -- Can you post an example of this please :)


  • mrangel

    Hi Thomas,

    There is no easy way of determining the last executed activity from within the execute method of a sibling activity. But there are a variety of different things you can do which ay achieve your goal.

    It might be as easy as having a property on your "accessing" activity that stores the value you want from the "target" activity and then binding (using ActivityBind class) the accessing activity's property to the target activity's property. From the execute method of the accessing activity, you can access the value you need by just getting your own property!

    If you need something more elaborate, where you must get a hold of the activity itself, then you can have a sring property on the activity that needs to do the "lookup" (find the previous, or some other activity in the workflow) that is the Name of the activity it needs. Not only does this allow you to find the activity at runtime, but it lets you perform validation on this activity if you desire, to ensure that it points to a valid activity. This is what the fetch would look like in the execute method:

    Activity targetActivity = executionContext.Activity.GetActivityByName(this.ActivityToFetch);

    If neither of these addresses your scenario, then you probably need to create a custom composite activity that will coordinate all of this for you, although this will have some limtations as well.

    Please let me know if you have any questions.

    Thanks!



  • How to access properties of the last used activity in a workflow