Wednesday, 14 December 2016

SOA Serive Client : WorkFlow service in Teamcenter

How about submiting the objects to workflow ?

//connection -> TC connection objects
//WorkflowService is from package com.teamcenter.services.strong.workflow
WorkflowService wfService = WorkflowService.getService(connection);

if(wfService==null)
{
 throw new Exception("The workflow service not found in Teamcenter.");
}

String[] arrObjectUID=new String{"qwerttt","dfreeXVyu"}
int[] arrTypes = new int[arrObjectUID.length];
Arrays.fill(arrTypes, 1);//Target attachment type to be initialized for all UIDs


ContextData contextData = new ContextData();
contextData.attachmentCount = arrObjectUID.length;//
contextData.attachments = arrObjectUID;//List of UID of objects to submit to workflow
contextData.attachmentTypes = arrTypes; //Types of attachment  EPM_target_attachment (target attachment) and EPM_reference_attachment (reference attachment).
contextData.processTemplate = processTemplate;//"ReleaseObjectsWorkflow";

//processname -> Name by which initiated workflow appear in the user mail box .
//processDescription -> Description for the initiated workflow
InstanceInfo instanceResponse = wfService.createInstance(true, null, processName, null,processDescription, contextData);

if(instanceResponse.serviceData.sizeOfPartialErrors() == 0)
 System.out.println("Process created Successfully");

else
{
    System.out.println("Error :"+instanceResponse.serviceData.getPartialError(0).getMessages());
    System.out.println("Error :"+instanceResponse.serviceData.getPartialError(0).getErrorValues());
    throw new Exception("Submit To Workflow: 001","Submit To Workflow - "+instanceResponse.serviceData.getPartialError(0).getMessages()[0]);

}
  
Explanation : Important API
InstanceInfo instanceResponse =wfService.createInstance(true, null, processName, null,processDescription, contextData);

1 comment:

  1. Can you show how to complete a workflow consists of review task through soa and assign only one user in select sign-off task.?

    ReplyDelete