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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Workflow Attributes

Status
Not open for further replies.

ShishirDwivedi

Programmer
May 9, 2010
8
0
0
JP
Hi,
I am trying to set the attributes of a work package in the following way:

1: I execute the startTask() function to retrieve the workackage.
2: I access the category Version of the work package.
3: I use this category version to get/set the attributes using attrGetValues/attrSetValues functions.

Now untill i set the attributes and update the category Version of the workpackage with the new attributes, all works fine. Even the updation of the work package using the UpdateTaskWork function returns zero. But , the attributes do not get updated in the work package. If i try to retrieve them again from the work package, the original and not the updated values are returned.

Here is the code:

public class task {

public static void main(String[] args) {
try{
int ID = 108490;
int tID =4;
String attName = "Document Approved";

LLValue map = new LLValue().setAssoc();
LLValue map2 = new LLValue().setAssoc();

LLSession session = new LLSession("blrkec88884d", 2099, "", "Admin", "infy123", null);
session.setEncoding("UTF-8");
System.out.println("CREATED SESSION : "+session.getStatus()+" , "+session.getStatusMessage());


LAPI_WORKFLOW lapiwf = new LAPI_WORKFLOW(session);

System.out.println("workflow object status " + lapiwf);
LLValue lAdditions = (new LLValue()).setList();


int i = lapiwf.AcceptTask(ID, ID, tID);

i = lapiwf.StartTask(ID, ID, tID, map);

System.out.println("Task Started = " + i);

System.out.println("map = " + map);

LAPI_ATTRIBUTES attributes = new LAPI_ATTRIBUTES(session);
LLValue temp = new LLValue().setList();

LLValue temp2 = new LLValue().setList();

LLValue catVersion = map.toValue(2).toValue("USERDATA").toValue("catVersion");
LLValue catVersion2;

System.out.println("catVersion = " + catVersion);

attributes.AttrGetInfo(catVersion, attName, null, temp);

System.out.println("Att Info" + temp);

int att = attributes.AttrGetValues(catVersion, attName, 5, null, temp2);
System.out.println(att + " ------attribute info-------- " + temp2);

System.out.println(temp2.toValue(0).isBoolean());
temp2.remove(0);
temp2.add(false);
System.out.println(temp2.toValue(0).isBoolean());


//att = attributes.AttrSetValues(catVersion, "In Scope?", 5, null, temp2);
att = attributes.AttrSetValues(catVersion, attName, 5, null, temp2);
map.toValue(2).toValue("USERDATA").setValue("catVersion",catVersion);
//att = attributes.AttrSetValues(catVersion, "In approved parts list?", 5, null, temp2);
//att = attributes.AttrGetValues(catVersion, "In Scope?", 5, null, temp);
att = attributes.AttrGetValues(catVersion, attName, 5, null, temp);
System.out.println(att + " ------attribute info-------- " + temp);

//map.toValue(2).toValue("USERDATA").setValue("catVersion",catVersion);

catVersion2 = map.toValue(2).toValue("USERDATA").toValue("catVersion");
att = attributes.AttrGetValues(catVersion2, attName, 5, null, temp2);
System.out.println(att + " ------intermediate-------- " + temp2);

//int i1 = lapiwf.UpdateWorkPackage(ID, ID, map);
i = lapiwf.UpdateTaskWork(ID, ID, tID, map);
System.out.println("Updation = " + i);

i = lapiwf.AccessWorkPackage(ID, ID, map2);
System.out.println("Task Started again = " + i);

catVersion = map2.toValue(2).toValue("USERDATA").toValue("catVersion");
att = attributes.AttrGetValues(catVersion, attName, 5, null, temp2);
System.out.println(att + " ------updated attribute info-------- " + temp2);

//att = attributes.AttrGetValues(catVersion, "In Scope?", 5, null, temp);
System.out.println("After Updation = " + temp2);

i = lapiwf.ListWorkflowInbox("Todo2", "", "", 1, 0, temp,temp2);
System.out.println(i + temp.toInteger() + "----------Task Status---------" + temp2);


i = lapiwf.EndTask(ID, ID, tID, "Approve");
System.out.println("End Task = " + i);
}
catch (Exception e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}

}


Any help will be appreciated.

Thanx
 
post your workflow map here and tell me how to run your code and I will help debug this and what version of livelink and java.At the outset it looks correct to me,but I can put builder and see if everything is going thru.
You can also do this if you have builder,you can run your code and put breaks in the right lapi calls and see if they are running as intended.

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008
 
HI,
Thanks for your reply.
You can run this code by using any valid livelink credentials in the below call.
LLSession session = new LLSession("blrkec88884d", 2099, "", "Admin", "infy123", null);

This code will run for executing a workflow task that will appear in a user's inbox when the workflow is initiated. So the following code will run for the user "Admin" in this case where he has a workflow task in his inbox.
You need to give a valid workId, subworkId, taskId and attribute name here:

int ID = 108490;
int tID =4;
String attName = "Document Approved";

In my case. "Document Approved" is a checkbox. (Type = 5)

Here's the sample output of the code:

CREATED SESSION : 0 ,
workflow object status com.opentext.api.LAPI_WORKFLOW@156ee8e
Task Started = 0
map = V{<TYPE,SUBTYPE,USERDATA,DESCRIPTION><1,1,108488,?><1,2,{?,V{<TASKID,USERID,USERNAME,STEPNAME,GIF,MODULENAME,DATESAVED,COMMENTS><0,1000,Admin,Start Step,16start.gif,webwork,D/2010/5/18:14:46:16,?><1,1000,Admin,<Unknown>,16user.gif,webwork,D/2010/6/8:11:0:33,?>}},?><1,3,A<1,?,catVersion=A<1,?,data=A<1,?,ID=1,Values={A<1,?,3=A<1,?,ID=3,Values={true}>,2=A<1,?,ID=2,Values={true}>>}>,catID=A<1,?,Type=2>,definition=A<1,?,DisplayName=Attributes,ValueTemplate=A<1,?,ID=1,Values={A<1,?,3=A<1,?,ID=3,Values={true}>,2=A<1,?,ID=2,Values={true}>>}>,Children={A<1,?,Required=true,DisplayName=Document Approved,Type=5,NumRows=1,ID=2,MaxRows=1,Search=false,FixedRows=true,Name=Document_Approved>,A<1,?,Required=true,DisplayName=File Attached,Type=5,NumRows=1,ID=3,MaxRows=1,Search=false,FixedRows=true,Name=File_Attached>},Type=-18,NumRows=1,ID=1,MaxRows=1,NextID=4,FixedRows=true,Name=Attributes>>>,?>}
catVersion = A<1,?,data=A<1,?,ID=1,Values={A<1,?,3=A<1,?,ID=3,Values={true}>,2=A<1,?,ID=2,Values={true}>>}>,catID=A<1,?,Type=2>,definition=A<1,?,DisplayName=Attributes,ValueTemplate=A<1,?,ID=1,Values={A<1,?,3=A<1,?,ID=3,Values={true}>,2=A<1,?,ID=2,Values={true}>>}>,Children={A<1,?,Required=true,DisplayName=Document Approved,Type=5,NumRows=1,ID=2,MaxRows=1,Search=false,FixedRows=true,Name=Document_Approved>,A<1,?,Required=true,DisplayName=File Attached,Type=5,NumRows=1,ID=3,MaxRows=1,Search=false,FixedRows=true,Name=File_Attached>},Type=-18,NumRows=1,ID=1,MaxRows=1,NextID=4,FixedRows=true,Name=Attributes>>
Att InfoA<1,?,Required=true,DisplayName=Document Approved,Type=5,NumRows=1,ID=2,MaxRows=1,Search=false,FixedRows=true,Name=Document_Approved>
0 ------attribute info-------- {true}
true
true
0 ------attribute info-------- {false}
0 ------intermediate-------- {false}
map = V{<TYPE,SUBTYPE,USERDATA,DESCRIPTION><1,1,108488,?><1,2,{?,V{<TASKID,USERID,USERNAME,STEPNAME,GIF,MODULENAME,DATESAVED,COMMENTS><0,1000,Admin,Start Step,16start.gif,webwork,D/2010/5/18:14:46:16,?><1,1000,Admin,<Unknown>,16user.gif,webwork,D/2010/6/8:11:0:33,?>}},?><1,3,A<1,?,catVersion=A<1,?,data=A<1,?,ID=1,Values={A<1,?,3=A<1,?,ID=3,Values={true}>,2=A<1,?,ID=2,Values={true}>>}>,catID=A<1,?,Type=2>,definition=A<1,?,DisplayName=Attributes,ValueTemplate=A<1,?,ID=1,Values={A<1,?,3=A<1,?,ID=3,Values={true}>,2=A<1,?,ID=2,Values={false}>>}>,Children={A<1,?,Required=true,DisplayName=Document Approved,Type=5,NumRows=1,ID=2,MaxRows=1,Search=false,FixedRows=true,Name=Document_Approved>,A<1,?,Required=true,DisplayName=File Attached,Type=5,NumRows=1,ID=3,MaxRows=1,Search=false,FixedRows=true,Name=File_Attached>},Type=-18,NumRows=1,ID=1,MaxRows=1,NextID=4,FixedRows=true,Name=Attributes>>>,?>}
Updation = 0
Task Started again = 0
0 ------updated attribute info-------- {true}
After Updation = {true}
4----------Task Status---------V{<WORK_WORKID,WORK_OWNERID,WORK_MANAGERID,WORK_STATUS,WORK_OWNERPERMS,SUBWORK_SUBWORKID,SUBWORK_TITLE,SUBWORK_STATUS,SUBWORKTASK_TASKID,SUBWORKTASK_PERFORMERID,SUBWORKTASK_TITLE,SUBWORKTASK_DATEMILESTONE,SUBWORKTASK_DATEDUE_MAX,SUBWORKTASK_DATEREADY,MAPTASK_STARTDATE,MAPTASK_TYPE,MAPTASK_SUBTYPE,MAPTASK_PRIORITY,WORK_OWNERID_NAME,WORK_MANAGERID_NAME,SUBWORKTASK_PERFORMERID_NAME,STATUS,PRIORITY,Permissions,CanSeeDetail,Subtype,DateAssigned,DateDue,DateDue_color,CreatedBy,_CreatedBy_Name,Name,RootRec,Location,GIF><108493,1000,1000,2,1023,108493,Workflow Map,1,4,1000,Final Approval,?,D/2010/6/10:10:8:5,D/2010/6/8:10:8:5,?,1,101,50,Admin,Admin,Admin,1,50,679,true,153,D/2010/6/8:10:8:5,D/2010/6/10:10:8:5,#000000,1000,Admin,Final Approval,R<Name=Workflow Map,SubType=189,GIF=?,Permissions=679,Work_WorkID=108493,SubWork_SubWorkID=108493,WORK_OWNERID=1000,WORK_MANAGERID=1000>,Workflow Map,?><115953,1000,1000,2,1023,115953,Shishir_test_workflow,1,15,1000,Initiator revision,?,?,D/2010/6/8:13:52:17,?,1,104,50,Admin,Admin,Admin,1,50,679,true,153,D/2010/6/8:13:52:17,?,#000000,1000,Admin,Initiator revision,R<Name=Shishir_test_workflow,SubType=189,GIF=?,Permissions=679,Work_WorkID=115953,SubWork_SubWorkID=115953,WORK_OWNERID=1000,WORK_MANAGERID=1000>,Shishir_test_workflow,?><108490,1000,1000,2,1023,108490,Workflow Map,1,4,1000,Final Approval,?,D/2010/6/10:9:49:4,D/2010/6/8:9:49:4,?,1,101,50,Admin,Admin,Admin,1,50,679,true,153,D/2010/6/8:9:49:4,D/2010/6/10:9:49:4,#000000,1000,Admin,Final Approval,R<Name=Workflow Map,SubType=189,GIF=?,Permissions=679,Work_WorkID=108490,SubWork_SubWorkID=108490,WORK_OWNERID=1000,WORK_MANAGERID=1000>,Workflow Map,?><108591,37507,37507,2,1023,108591,testWorkflow,1,4,1000,Admin,?,?,D/2010/5/18:16:25:48,?,1,101,?,helix1,helix1,Admin,1,50,679,true,153,D/2010/5/18:16:25:48,?,#000000,37507,helix1,Admin,R<Name=testWorkflow,SubType=189,GIF=?,Permissions=679,Work_WorkID=108591,SubWork_SubWorkID=108591,WORK_OWNERID=37507,WORK_MANAGERID=37507>,testWorkflow,?>}
End Task = 500408

I understand it looks too rugged but for an experienced person, i believe it wouldn't be too tough to decipher.

I have used a diferent workId in the EndTask() call because i didn't wan't the task to finish. Then i have to give a new taskId each time i run the code. So "End Task = 500408" indiacting the End Task call is not executed properly is fine.

The issue is, the checkbox attribute when retrieved the first time is true. I am setting it to false in the code and updating the work package. When i am retrievng that attribute again from the package, it is again showing as true.

Hope this explanation helps.

 
Hi Shishir,
I was offering to help because I kind of know livelink,workflow,oscript ,lapi very intimately,unfortunately your code cannot be debugged because all workflows are based on maps that a organization paints.My maps will contain data that I make up,yours will contain yours .So if another company,another person is to look at your code OT has given a function on the map of the workflow saying "Export Map"
For the most part I thought I could import the map and help you.I don't have time to reverse engineer your WF.For the most part I think your wf has this WF attributes
Document Approved,
File Attached

If I am not mistaken checkboxes documentation of lapi or how to pass them is documented wrong

Without the map I am helpless

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008
 
Hey Appnair,
Thanks for the try.
I understand your helplessness.
May be what you can do is provide me a sample code of how to set a checkbox workflow attribute using JAVA Lapi.
I think that would suffice.

Thanks again

 
Hi Shishir,
I made it working.As I said the documentation is kind of erroneous and you had some errors as well.Look for APPU where the code has changed
Code:
import com.opentext.api.*; 		// import the LAPI classes
import java.io.*;
import java.util.*;
import java.lang.*;

public class taskImprovedByAppu {

    public static void main(String[] args) {
        try{
                //int ID = 108490;
                //int tID =4;
                //APPUS VALID TASKS FOR SHISHIR MAP
                int ID = 12057;
                //int tID =1;
                int tID =4;
                String attName = "Document Approved";

                LLValue map = new LLValue().setAssoc();
                LLValue map2 = new LLValue().setAssoc();

                LLSession  session = new LLSession("localhost", 2099, "", "Admin", "Admin", null);
                session.setEncoding("UTF-8");
                System.out.println("CREATED SESSION : "+session.getStatus()+" , "+session.getStatusMessage());


                LAPI_WORKFLOW lapiwf = new LAPI_WORKFLOW(session);

                System.out.println("workflow object status " + lapiwf);
                LLValue lAdditions = (new LLValue()).setList();


                int i = lapiwf.AcceptTask(ID, ID, tID);

                i = lapiwf.StartTask(ID, ID, tID, map);

                System.out.println("Task Started = " + i);

                System.out.println("map = " + map);

                LAPI_ATTRIBUTES attributes = new LAPI_ATTRIBUTES(session);
                LLValue temp = new LLValue().setList();

                LLValue temp2 = new LLValue().setList();

                LLValue catVersion = map.toValue(2).toValue("USERDATA").toValue("catVersion");
                LLValue catVersion2;

                System.out.println("catVersion = " + catVersion);

                attributes.AttrGetInfo(catVersion, attName, null, temp);

                System.out.println("Att Info" + temp);

                int att = attributes.AttrGetValues(catVersion, attName, 5, null, temp2);
                System.out.println(att + " ------attribute info-------- " + temp2);

                System.out.println(temp2.toValue(0).isBoolean());
                temp2.remove(0);
                temp2.add(false);
                System.out.println(temp2.toValue(0).isBoolean());

                /************APPU CHANGES 06/10/2010 DOCUMENTATION*************************************
                CHECKBOXES DOCUMENTATION IS WRONG BOOLEAN IS ONLY ON DEFINITION
                SHISHIR IS PASSING FALSE/TRUE IN HIS CATEVERSON BUT IN BUILDER UNLESE
                THE LIST LOOKS LIKE {0} OR {1} IT DOES NOT WORK HENCE I ADDED A LIST AND PASSED
                0 OR 1 TO IT**************************************************************************/



               //SHISHIR ORIGINAL LINE
               // att = attributes.AttrSetValues(catVersion, attName, 5, null, temp2);
                LLValue boolConvert = new LLValue().setList();
				       boolConvert.add(1); //sets to true the checkbox
                       //boolConvert.add(0);//sets to false the checkbox TOGGLE THIS IN CODE

                      /* NOTE THE USE OF 5 FOR CHECKBIOX IS USEFUL ONLY IF YOU ARE CREATING IT FROM SCRATCH
                       FOR SETTING IT YOUR CHOICES ARE
                       Category and Attribute functions use the following value type constants:

					   ATTR_DATAVALUES    // non-default attribute values
					   ATTR_DEFAULTVALUES // default attribute values*/


                  att = attributes.AttrSetValues(catVersion, attName, LAPI_ATTRIBUTES.ATTR_DATAVALUES , null, boolConvert);

                  //APPU CHANGES 06/10/2010 *********************************************************************END

                map.toValue(2).toValue("USERDATA").setValue("catVersion",catVersion);
                //att = attributes.AttrSetValues(catVersion, "In approved parts list?", 5, null, temp2);
                //att = attributes.AttrGetValues(catVersion, "In Scope?", 5, null, temp);
                att = attributes.AttrGetValues(catVersion, attName, 5, null, temp);
                System.out.println(att + " ------attribute info-------- " + temp);

                //map.toValue(2).toValue("USERDATA").setValue("catVersion",catVersion);

                catVersion2 = map.toValue(2).toValue("USERDATA").toValue("catVersion");
                att = attributes.AttrGetValues(catVersion2, attName, 5, null, temp2);
                System.out.println(att + " ------intermediate-------- " + temp2);

                //int i1 = lapiwf.UpdateWorkPackage(ID, ID, map);
                i = lapiwf.UpdateTaskWork(ID, ID, tID, map);
                System.out.println("Updation = " + i);

                i = lapiwf.AccessWorkPackage(ID, ID, map2);
                System.out.println("Task Started again = " + i);

                catVersion = map2.toValue(2).toValue("USERDATA").toValue("catVersion");
                att = attributes.AttrGetValues(catVersion, attName, 5, null, temp2);
                System.out.println(att + " ------updated attribute info-------- " + temp2);

                //att = attributes.AttrGetValues(catVersion, "In Scope?", 5, null, temp);
                System.out.println("After Updation = " + temp2);

                i = lapiwf.ListWorkflowInbox("Todo2", "", "", 1, 0, temp,temp2);
                System.out.println(i + temp.toInteger() + "----------Task Status---------" + temp2);


                i = lapiwf.EndTask(ID, ID, tID, "Approve");
                System.out.println("End Task = " + i);
        }
        catch (Exception e1)
        {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

}
}

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008
 
Thanks a lot Appu.
It worked!!
You are a lifesaver. :)
Like you said, the erroneous documentation did me in.
Any pointers to the correct documentation?

Thanx a lot again.
 
There is no correct documentation.You need to know oscript and with that you can debug lapi problems which is what I did.
LAPI will not get bug fixes(patches) as it is being superceded by Enterprise web Services and Enterprise Library Services both of these methods(have different uses) have started getting more and more useful code and examples(LAPI at one time did not have even one line of finished code for public consumption).It is people like Greg and me and a whole lot of selfless livelink developers who really stared putting code out for free for public consumption.I have not still embraced ELS or EWS as my work routine does not need me to but sensing your urgency thought of helping you.

Try to learn livelink in the mean time and then you can understand a whole lot of its programming.There are no short cuts in this as I have found out.BTW I saw a similar thread at the KB,was it you or your colleaugue who posted that.

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top