Archive for the ‘Teamworks’ Category

How to get Teamworks Task Participant Group Name

Monday, January 12th, 2009

use getTaskAssignmentInformation method in TaskUtilities class.

For example:


// The parameter is a system variable that contains the task_id
tw.local.result = Packages.bpm.util.TaskUtilities.getTaskAssignmentInformation(tw.system.task_id);
if (tw.local.result.name =='group'){
  tw.local.groupName = tw.local.result.value;
}

This comes in handy, especially in our shop where the lane participant corresponds to a Lotus Notes mail group. In my real world case, I use this method to get the group and send an email notification to the participants informing them they have been assigned a task. I also use this for reminder notifications when participants are naughty and do not work off their tasks in a timely manner.

In my case, participants are always mapped to a Lotus Notes group, but your case my be different. If your participant is not a group, the groupName element in TaskAssignmentInfo will be empty, so you will need to use the userListDelim element value (each user value is separated by comma) to determine participant(s).

getTaskAssignmentInformation xml:

TaskInfo

How to pass parameter to Teamworks service from a browser

Wednesday, January 7th, 2009

My service name is ‘Display History’. This service displays the history for a given instance. For example, the service displays all the associated tasks that have been processed - both open and closed - up until the time the service is executed for a given instance.

Let’s say I want the history for instance 10313.  In the service, I defined an input local variable, ‘instanceId’ that is a string - see figure 1. To pass an instanceId=10313 to the service from a web browser, I use the following URl:

http://localhost:7001/teamworks/process.lsw?zWorkflowState=5&zProcessName=Display%20History&tw_local_instanceId=10313

Note: Teamworks requires the parameter to include underscores, so tw_local_instanceId corresponds to service local variable instanceId as is shown in figure 1.

Invoking the above URl from a browser will start the service, pass 10313 to the service and return a list of processed tasks - see figure 2. Note, when I get a chance, I will include the close date (CLOSED_TIMESTAMP) and/or status (STATUS) so users can determine where the task is in the lifecycle, and, more importantly, they will know who to call and pester when a task is sitting idle w/o action. In my ‘real life’ case, I send reminder emails to participants every so often just to keep them in the game.

Teamworks Service Input Parameters Screenshot

Figure 1

teamworksservicehistoryoutput

Figure 2


Additional Info:

See attachment below for SQL query that returns all the tasks for an instance.

See attachment below for the xsl stylesheet that I used to produce the history report. I removed styles for simplicity as I did not want to get into css at this time.

Transform Service:

  1. Input: 1) xmlString: the xml used in the transform, 2) xslUrl: the url for the stylesheet
  2. Output: 1) result: the transformed results

var factory = new Packages.org.apache.xalan.processor.TransformerFactoryImpl();
var transformer = factory.newTransformer(new Packages.javax.xml.transform.stream.StreamSource(tw.local.xslUrl));
var input = new Packages.javax.xml.transform.stream.StreamSource(new java.io.StringReader(tw.local.xmlString));
var stringwriter = new java.io.StringWriter();
var result = new Packages.javax.xml.transform.stream.StreamResult(stringwriter);
transformer.transform (input, result);
tw.local.result = stringwriter.toString();

Note: Special thanks goes to Jeoff Wilks from Lombardi for providing assistance with this service.

Attachment:

history.xsl

history.sql

Reference:

Lombardi Wiki Reference