Team member becomes owner of a task

Last post 05-15-2008, 12:38 AM by Jacques. 1 replies.
Sort Posts: Previous Next
  •  11-28-2007, 4:20 PM 20136

    Team member becomes owner of a task

    I have a task in a K2 BlackPearl workflow that is assigned to a group of users. I want the person that actions the task to then 'own' subsequent tasks which are assigned only to them.

    I'm using a workflow that is integrated to InfoPath and there are two InfoPath client activities. Let's call the first activity 'TEAM Activity' and then the subsequent activity 'USER Activity'.

    One of the good things about BlackPearl is the ability to assign a Destination User not just to a user or a role but to a data field.
    This solution uses that ability, so I created a DataField called 'DestinationUser' and an Environment variable called 'Domain'.

    It also uses a field from the InfoPath form which stores the current user. Just use the userName() function as the default value and you have the name of the current user. See this post http://blogs.msdn.com/timpash/archive/2006/08/22/712663.aspx

    1. TEAM Activity is assigned to the Role of the 'A Team' where membership of this role is determined through K2.
    2. So when you run through the InfoPath client wizard, select the 'A Team' role in the usual way.
    3. Now on the TEAM Activity create a Server Code event and make sure it is underneath the InfoPath client event.
    4. In the Server Event add the following code:

    System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
    doc.LoadXml(K2.ActivityInstanceDestination.XmlFields["Root"].Value);

    // call custom utility that uses SelectSingleNode to retrieve value of

    //node using namespace
    string CurrentOwner = Utils.GetXMLValue(doc, "my:CurrentOwner");

    K2.ProcessInstance.DataFields["NewOwner"].Value = CurrentOwner;
    // Set DestinationUser datafield
    K2.ProcessInstance.DataFields["DestinationUser"].Value = K2.StringTable["Domain"] + @"\" + K2.ProcessInstance.DataFields["NewOwner "].Value.ToString();


    NOTE the use of K2.ActivityInstanceDestination.XmlFields["Root"] on the second line. Using ProcessInstatance won't work because it hasn't been updated yet.

    On the USER Activity when you run through the InfoPath client wizard, select the Destination User to be the 'DestinationUser' data field.

    A word of caution. Bad things happen if you don't set the DataField to a value. K2 will understandably throw a runtime error as it doesn't know who to assign the client activity to. Also think through the implications of redirecting a task. You may need to reset the current user on other activities. But I've found this trick really useful.

  •  05-15-2008, 12:38 AM 23811 in reply to 20136

    Re: Team member becomes owner of a task

     

    Nice tip.

    To eliminate the server activity you should add a SmartObject to your solution to  save some Process Information.

    You could easily add this SmartObject as a secondary data source to your InfoPath form. You should then on submittion update the CurrentOwner property of your SmartObject to the Username() and call the save method of your SmartObject.

     

    Now in your process you could just add a Reference to the SmartObject's Load method. You can now use the CurrentOwner property value as the destination of any subsequent activities.


    The statements and opinions made in my postings are my own, and do not reflect the opinions of SourceCode Technology Holdings, Inc. or its subsidiaries. All information is provided as is with no warranties, express or implied, and grants no rights or licenses.
View as RSS news feed in XML