8 thoughts on “MSDN Workflow Stuff

  1. Hi Fred,
    I am really interested in your improvement to the wssTaskActivity. I am talking about the OnTaskCreated workflow action that you eluded to in your writings.

    Can you share the improved version (V2)?

    Thanks,
    Ofer

  2. Hi Fred,
    I hate to bug you again… Would you be able point me to any resource that will help me figure out how to incorporate onTaskCreated into the wssTaskAcrivity? It has been a source of pain for me for the past few days as I am trying to get access to the task on the list, but I cannot get the taskID on the task list…

    Reading the blogs, you seem to be familiar enough to shed some light on the topic.

    Any help will be appreciated. Please email me if you can.

    Thanks,
    Ofer

  3. I tried to insert the OnTaskCreated event into WssTaskActivity as defined in version 1.3 of the SDK, but it did not fire reliably, so I took it out. A kludge work-around is to put the WssTaskActivity inside a ConditionedActivityGroup and have a sequence of activities that “spins” while waiting to see if the task has a valid ID (it won’t until it has been serialized by the run-time system). It makes the workflow very complex, but I fear that’s the best we can do until sometime in 2010 or 2011 when the next version of SharePoint (version 2010?) arrives with hopefully better run-time support for this basic need.

  4. ReplicatorActivity Example.
    1st – This is all new to me. Received some poor training, but I’m living with it and we are doing most of our work custom. No infopath.

    Here is my last challenge.

    I need this to send updates to various users who information we are pulling from the item out of our document list. email1, email2, email3, etc… are in the list.

    This list is not fixed in size so it could be 1 to however many users.
    I need to notify them initially there is a task.
    I need to notify them when that task has been updated.
    I need to notify them when it is complete.

    This came up after I designed my workflow using a conditioned activity group which works fine for one, but again I need to get this set for multiple individuals.

    Any help would be greatly appreciated.

    Sharepoint2007, Moss, No infopath, VS2008 using VB.
    I can translate between C# and VB.

    Thanks!

    1. I like to use a Conditioned Activity Group to hold, among other things, a Replicator of the composite task activity (project in the samples is called something like ECMTaskActivity) that comes with the SharePoint SDK & ECM Starter Kit. That composite activity allows you to send an email when the task is created and, in your case, send another email when the task is updated (OnTaskChanged event that fires indirectly from inside the ECMTaskActivity’s equivalent event handler) and send another email, via the Replicator’s OnChildActivityCompleted (although you need to separately keep track of which task just completed). I tend to run all my Replicators in Execution mode Parallel, whether they need to or not because I’m a creature of habit and most people don’t care about what order the replicated child activities are completed in. The other reason to surround the Replicator with a CAG is that if push comes to shove (e.g., a drop dead due date), you can always set the CAG’s Until condition to true and BAM! Any unfinished child activities (tasks in this example) go bye-bye instantly.

      Go get the latest SharePoint SDK and ECM Starter Kit (1.5 is the latest, I believe) and pull out a copy of the composite Task activity and study how it works (it’s used in most of the workflow examples in that kit). I modified it a bit to be “less chatty” (darn thing puts too many entries in Workflow History list for my money, but you might not mind and will use it “as is”).

      To summarize:

      1. Drop the CAG on the design surface and make sure you can control it’s Until condition programattically. To state the obvious, the intial value of the Until condition’s property that is (probably rule based) should be False.

      2. Drop the Replicator inside a “leg” of the CAG. If you have two different sets of tasks that both need to be controlled by the same CAG (e.g., ReviewTaskReplicator, ApproverTaskReplicator), you’ll have two “legs” inside your CAG. I often have a third leg with a fancy set of logic to figure out when the “drop dead due date” will be occurring so it can “reach out and touch” the CAG’s Until condition to set it to true. Also, change the execution style from the default sequential to parallel. Don’t bother trying to control the When condition of that leg of the CAG. That’s because you usually only need to make one trip through the complete Replicator “cycle” and that’s the default CAG behavior in the absence of an explicit When condition.

      3. If all you are replicating are instances of ECMTaskActivity that’s the only thing that needs to go inside the Replicator in terms of drag-n-drop from the toolbox. This “there’s only one thing being spun up by the replicator” type of design is the primary reason I like the ECMTaskActivity (or at least my slightly muffled version of it).

      4. You’ll need a module level List that is at a minimum, empty (not NULL!!! A null replicator list is guaranteed to make your Replicator have a hissy fit).

      5. Use the one-time replicator initialization event to populate the List with information about the peope involved in the tasks. The ECM Starter Kit has some examples of how to go about this.

      6. You will need to code the On Replicator Child Initialized event handler to grab the current instance (not the template like so many BAD examples on the internet show) of the List and use it to populate the properties of the ECMTaskActivity instance (not the darn template!!).

      7. If you want to know when the last of the parallel tasks has finished (or was killed because you set the CAG’s until condition to True while there were some active, unfinished tasks), perhaps to send a “final outcome of this phase of the CAG” type of email (e.g., Jacob gets the booby prize for being the last person out of a dozen people to finish their assigned Approver task) to all the “participants” of the workflow.

      The above pattern is something I find quite useful because it allows me to do a lot of things in parallel (via the CAG) that involve not-known-how-many-until-run-time set of tasks that need to run in parallel with the ability to include a sequence that includes a DelayActivity that wakes up every few (configurable) minutes/hours to see if it should enforce a due date on all the unfinished tasks (by setting the CAG’s Until condition to true).

      If you want to get really fancy (and very dangerous), you can look at running the AlterTask method on any unfinished tasks OUTSIDE OF THE REPLICATOR that spun them up to provide a more “graceful” way of ending them compared to the bloody mess that setting the CAG’s Until Condition to true provides.

  5. Hi – thanks for you posts here and elsewhere about how to use the replicator and the best way to access the child tasks (instance rather than template). I’m doing something very similar to what you’re describing – have a CAG with a replicator (activities are WsstaskActivity). I’m trying to add additional activities to the replicator with a workflow modification – but seem to have problems getting this to work when inside a CAG (works fine outside a CAG). I get the dynamic replicator when the ChildInitialized event runs for the first of the initial data and store it in a global member on the workflow. In the workflow modify event I try to add additional child data to the dynamic replicator stored on the workflow. No error is raised and when I subsequently check the replicator it has the additional items added in the ChildData. But the ChildInitialized event isn’t raised for the new items added to the replicator and no new tasks are created for the newly added data. Any ideas on how to get the replicator to respond to new data items when inside a CAG?

    Cheers

    1. While I have not tried the specific scenario you describe, from what I know about a Replicator, once the Replicator’s Initialized event has completed, you cannot dynamically add more items to the ChildData list. Also, your ChildData list should be a serializable list that is global to the workflow when it starts. Don’t wait until the workflow modification kicks in to make a new list.

  6. Hey fred,

    I need to replicate task acitivity for a group of people.I used the replicator(parallel),WSS task activity as you described here http://social.msdn.microsoft.com/forums/en-US/sharepointdevelopment/thread/0a395dd8-ba02-4796-af30-b3f942eb3a63.The tasks get created perfectly fine.But onTaskChanged event does not fire.

    Can you please send me a working sample code?

    And i needed to use a custom task edit form , how could i include the createTaskWithContentType activity’s funtinality within the wssTaskActivity?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s