Home > DOCUMENTUM > Handling Workflows and Tasks in DCTM using DFC

Handling Workflows and Tasks in DCTM using DFC

April 26, 2010

How can we Start workflows in a docbase using docbase right from getting the attachment document , getting the workflow template , creating a workbuilder to start a workflow ,getting the First Activity,getting the Package Name , Port and Package DocType ,Adding the attachment document to List ,Adding a Package to Workflow Builder and finally how do we view the tasks in INBOX ?

The tried out example below will give you the step by step procedure of starting a workflow in a docbase and viewing tasks in inbox in DCTM using DFC.

Starting workflow in a docbase:

public void startWorkflow() throws Exception {

IDfSysObject sysObj = (IDfSysObject) idfSession. getObjectByQualification(“dm_document where object_name=’Test-Document'”);

IDfProcess process = (IDfProcess) idfSession.getObjectByQualification (“dm_process where object_name=’temp_workflow'”);

IDfWorkflowBuilder builder = idfSession.newWorkflowBuilder(process.getObjectId());

IDfId wfId = builder.initWorkflow();

IDfList startActivityNames = builder.getStartActivityNames();

IDfList startActivities = builder.getStartActivityIds();

String activityName = startActivityNames.getString(0);

IDfId activityID = (IDfId) startActivities.get(0);

IDfActivity activity = (IDfActivity) idfSession.getObject(activityID);

int nPorts = activity.getPortCount();

String InputPortName = null;

String PkgType = null;

String PkgName = null;

for (int j=0; j<nPorts; j++) {

System.out.println( “Port Name: ” + activity.getPortName(j) + “, ” + “Port Type = ” + activity.getPortType(j) );

if (activity.getPortType(j).equals( “INPUT” ) ) {

InputPortName = activity.getPortName(j);

PkgType = activity.getPackageType(j);

PkgName = activity.getPackageName(j);

}
}

IDfList dfList = new DfList();

dfList.append(sysObj.getObjectId());

IDfId wfId2 = builder.runWorkflow();

builder.addPackage(activityName, InputPortName, PkgName, PkgType, null, false, dfList);

System.out.println(“Package added”);

}

Viewing task in inbox:

public void getInbox() throws Exception {

IDfCollection tasks = idfSession.getTasks(“temp”, DfSession.DF_TASKS, “name, date_sent, message “, “task_name”);
try {
while (tasks.next()) {
IDfWorkitem wi = (IDfWorkitem) idfSession.getObject
(tasks.getId(“item_id”));
IDfId queueItemId = wi.getQueueItemId();
IDfQueueItem qi = (IDfQueueItem) idfSession.getObject(queueItemId);
System.out.println(tasks.getString(“sent_by”) +” “+
tasks.getString(“task_name”)+” “+ tasks.getString(“date_sent”)+” “+ tasks.getString(“message”)+” “+ qi.getItemName());
IDfActivity dfActivity=wi.getActivity();
System.out.println(“\tActivity Information : “+dfActivity.getString(“object_name”));
IDfCollection packColl= null;
try {
packColl=wi.getPackages(“”);
while(packColl.next()) {
IDfSysObject sysObj=(IDfSysObject) idfSession.getObject (packColl.getId(“r_component_id”));
System.out.println(“\t Package Information: ” + sysObj.getString(“object_name”));
}

} finally {
if(packColl != null)
packColl.close();
}

// to finish a Task or Workitem
//finishTask(wi);
}

} finally {
if(tasks!=null) tasks.close();
}
}

%d bloggers like this: