adrian_hara

Hello,

I'm trying to build a simple activity named WaitForTaskComplete. Basically it's a sequence activity which contains a WhileActivity which contains a OnTaskChanged (from SPS) activity. The while loops until the task changed is marked as complete.

My problem is that the OnTaskChanged activity has a CorrelationToken and I have to a) expose it (promote it) on the WaitForTaskComplete activity and b) once the user sets this token on the WaitForTaskComplete activity I have to then set it to the child OnTaskChanged activity.

Regarding a)

  • I tried defining a dependency property on the WaitForTaskComplete activity of type CorrelationToken, but for some reason I can't choose the name of the token in the property grid, once I drop and use the activity in a workflow. It might be due to the fact that the CorrelationTokeTypeConverter with which the properties of type CorrelationToken for activities in the BAL are decorated is marked as internal Sad Any other way to do it

Regarding b)

  • because of a) I defined two string properties on my activity, TokenName and TokenOwnerActivityName. But the question is how can I actually set the token of the child activity. It seems I can't set it at runtime (overriding Initialize or something) so I'm guessing it must be set at design time. But how I tried making my activity implement ISupportInitialize, but the designer seems to just ignore this and generates no code (in the .designer file) to call methods of this interface

Any ideas are greatly appreciated, thanks!



Re: Windows Workflow Foundation Exposing and setting child activity correlation token

Tombo_BE

Hello Adrian,

This is a coincidence, but I have almost the exact same problem at the moment. Some SP related activities in my own activity need a correct correlation token. I found this post http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=468924&SiteID=1 about the ISupportInitialize interface, so decided to give it a shot. But as you found out too, no component seem to call EndInit. So I tried calling it manually after the InitializeComponent of the constructor of my workflow. This seems to do the trick. But I don't really think this is the way to go, as each workflow willing to use my activity has to add this manual call code.

Hope this kinda helps.

Kind Regards,

Tom





Re: Windows Workflow Foundation Exposing and setting child activity correlation token

adrian_hara

Thanks for the workaround, I will definitely try it.

I have to say though that I'm somewhat surprised at the lack of support on what I'd expect to be normal, everyday workflow issues. I mean, anyone who's developing a workflow slightly more complicated than Helloworkflow should run into these issues sooner or later. Still, I can't seem to find any documentation, concepts, implementation or whatever, on the net, which is dissapointing.





Re: Windows Workflow Foundation Exposing and setting child activity correlation token

adrian_hara

I've tried calling it right after InitializeComponent and I get a weird compilation error "MissingMethodException" for EndInit. It's weird because the method is there and calling it from another method of the workflow (so not the constructor) it compiles just fine. It's beyond me why I get that error when calling from the constructor (I tried both calling it directly and through an interface cast)




Re: Windows Workflow Foundation Exposing and setting child activity correlation token

Tom Lake - MSFT

As you mentioned the WaitForTaskComplete activity is from SharePoint, a better place to ask the question would be the SharePoint - Workflow forum found at http://forums.microsoft.com/MSDN/ShowForum.aspx ForumID=1207&SiteID=1.




Re: Windows Workflow Foundation Exposing and setting child activity correlation token

adrian_hara

No offense, but I think you didn't read my first post carefully. The WaitForTaskComplete activity is a custom activity I'm trying to develop. It contains a OnTaskChanged activity, which is indeed from Sharepoint, but for this discussion it doesn't really matter. Let's just suppose I'm trying to write custom activity A which contains an activity from the Base Activity Library, let's call this activity B. Now, B has a correlation token. How would I, as the developer of A, expose this token to the user of my (A) activity, and when would be the time to set it (by this I mean setting it from code of A).




Re: Windows Workflow Foundation Exposing and setting child activity correlation token

Tom Lake - MSFT

You don't want the value of a correlation token property to change and the only way to guarantee that is to make it a Metadata property, which is what all the WF activities have done. I don't know about the WaitForTaskComplete activity but my guess is they would have don't the same this. So it is not possible to expose the property like you want to do.




Re: Windows Workflow Foundation Exposing and setting child activity correlation token

adrian_hara

Thanks for the answer. Just to make it extra clear: the WaitForTaskComplete activity is NOT a Sharepoint activity. It's one developed by me.

But if what you're saying is true, then there's no way to create custom activities that CONTAIN activities having a correlation token





Re: Windows Workflow Foundation Exposing and setting child activity correlation token

Tom Lake - MSFT

It only makes sense when the correlation is self contained. Consider the situation where you create a get quote activity. You would probably want to have multiple instances running and each instance should receive the quote back from the same supplier that it sent the request out to.






Re: Windows Workflow Foundation Exposing and setting child activity correlation token

adrian_hara

Ok, that's correlation. But if I want to aggregate an activity which needs correlation, is it possible Or do I have to implement IEventActivity and do all the work myself