Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically assigning comments, user and attributes

Status
Not open for further replies.

DilipN

Programmer
Jan 28, 2005
17
US
Dear Friends ,

I have a very simple 2 step workflow (initiate and approve)Using Java API's I initiate this workflow and now i would like to dynamically assign the approver also i would like to add some comments which will be passed to next step. i have attached my code with this message.
i am able to reassign task using reassignTask() method,
but i want to change the comments and attributes.
any help is will be usefull. I think i am missing doing some silly mistake.
Please help.

Thank You in advance for any help.

Dilip.


import com.opentext.api.*;
public class WorkFlowSample
{
private static String Server = "localhost"; //livelink host
private static int Port = 2099; //livelink server port see opentext.ini
private static String DFT = ""; //default database file or schema
private static String User = "Admin"; //username
private static String Pass = "livelink"; //passwd
public static void main(String[] args)
{
try
{
LLSession session;
LAPI_DOCUMENTS doc;//library object
LAPI_WORKFLOW flow;//workflow object
LLValue value=new LLValue();
int workFlowStatus = 0 ;
session = new LLSession (Server, Port, DFT, User, Pass);
doc = new LAPI_DOCUMENTS (session);
flow = new LAPI_WORKFLOW (session);
LLValue LLvalueWP=new LLValue();
int volID, objID,versionID;
if (doc.AccessEnterpriseWS(value) == 0)
{
objID = value.toInteger("ID");
volID = value.toInteger("VolumeID");
LLValue map = ( new LLValue() ).setRecord();
//20646 is a Workflow id
workFlowStatus = flow.LoadMap(-2000,20646,0,map);
LLValue workIDValue = ( new LLValue() );
LLValue lAdditions = (new LLValue()).setList();
//lAdditions.add(5494); // this is a document ID
flow.StartWorkflow(map,"Sample Workflow .... ",null,workIDValue);
int liWorkID = workIDValue.toInteger();
// updating work Package
LLValue workPackageID = ( new LLValue() );
LLValue lWorkPackage = (new LLValue()).setRecord();
flow.AccessWorkPackage(liWorkID,liWorkID,lWorkPackage);
for (int i=0 ; i < lWorkPackage.size() ; i++)
{
LLValue lRecord = lWorkPackage.toValue(i);
if (lRecord.isRecord())
{
if (1 == lRecord.toInteger("SUBTYPE"))
{
//5494 is document ID
lRecord.setInteger("USERDATA",5494);
}
if (2 == lRecord.toInteger("SUBTYPE"))
{
lRecord.setString("USERDATA"," This is my new Comment... ");
}
}
}
flow.UpdateWorkPackage(liWorkID,liWorkID,lWorkPackage);
//flow.UpdateTaskWork(liWorkID,liWorkID,1,lWorkPackage);
//flow.StartTask(liWorkID,liWorkID,1,lWorkPackage);
System.out.println(" Done ...");
}
}
catch (Exception e)
{
System.out.println(e.getMessage() );
e.printStackTrace ();
}
}
}
 
We noticed an issue with Livelink 9.2 and workflow commments in LAPI. The comments structure has to be in a list format. The underlying code on the server will not process the comments data unless it is in a list format. Try something like this (only the relevant parts are shown):

LLValue definition = ( new LLValue() ).setAssocNotSet();
if ( ( type == 1 ) && ( subType == 2 ) )
{
row = table.toValue( i, "USERDATA" );
//check if this is a list. If not delete & create a list
if (row.isList()) {
row.setString( 0, comments );
}
else {
rowlen = row.size();
for (j = 0; j < rowlen ; j++)
{
row.remove(j);
}
row = definition.setList();
row.add(0);
row.setString( 0, comments );
}
}
 
Thank you very much for your response. I will try this. Earlier I did try the half part of what you have mentioned i.e
if (row.isList()) {
row.setString( 0, comments );
}

I will try the else part & see if that works.

I was using Livelink 9.1 & i recently upgraded it to 9.2. I hope it works.

Thank you verymuch for your response.

Thank you once again


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top