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

Problem adding document in folder with required Category

Status
Not open for further replies.

Pilsieboy

Programmer
Sep 12, 2007
8
NL
Hi all, I am struggeling with a kind of newbie problem :-S It shouldn't be that hard but I cannot find out what I do wrong. Hopefully someone can help me out!

I am trying to add a simple .txt document to a folder ("FolderX") with a required Category ("CategoryX") which has a required Attribute ("AttributeX").
I can access the enterprise workspace but when calling the function CreateObjectX an error occurs (see //// THE ERROR OCCURS HERE //// in the sourcecode).

Whatever I am trying, everytime I get the same error message:
Session failure status is 101101 (0x101101)
Message=Could not get results.
errMsg=
apiError=

Any help is welcome! Thanks in advance.

//I left some code out here... (accessing is not the problem)
// Access the Enterprise Workspace
LLValue pwsInfo = (new LLValue()).setAssocNotSet();
if (doc.AccessEnterpriseWS(pwsInfo) != 0)
{
Console.WriteLine("Enterprise Workspace access Failed.");
GetErrors(session);
return;
}
else
{
Console.WriteLine("Accessed Enterprise Workspace.");

//Define the parent object's dataID and volumeID (also called ownerID)
dataID = 41246; //"FolderX" FolderID
volumeID = pwsInfo.toInteger("ID");
}

//Create the objID assoc necessary for some category functions
LLValue objID = (new LLValue()).setAssocNotSet();
objID.add("ID", dataID);

//First, obtain a list of the folder's categories
LLValue catIDList = (new LLValue()).setAssocNotSet();
if(doc.ListObjectCategoryIDs(objID, catIDList) != 0)
{
Console.WriteLine("ListObjectCategoryIDs Failed.");
GetErrors(session);
return;
}
else
Console.WriteLine("Retrieved Category Listing.");

//loop through the categories and retrieve the catVersion
LLValue catID = (new LLValue()).setAssocNotSet();
for(int i=0; i < catIDList.size(); i++)
{
if((catIDList.toValue(i).toString("DisplayName")).CompareTo("CategoryX") == 0)
{
catID = catIDList.toValue(i);
}
}

//Now load the category version for this category from the folder
LLValue catVersion = (new LLValue()).setAssocNotSet();
if(doc.GetObjectAttributesEx(objID, catID, catVersion) != 0)
{
Console.WriteLine("GetObjectAttributesEx Failed.");
GetErrors(session);
return;
}
else
Console.WriteLine("Retrieved Category Version.");

//Now set the "Required Text Attribute" attribute
LLValue attrValuesPath = (new LLValue()).setAssocNotSet();
LLValue attrValues = (new LLValue()).setList();
attrValues.add("TestAttributeValue");

if(attr.AttrSetValues(catVersion, "AttributeX", LAPI_ATTRIBUTES.ATTR_TYPE_STRFIELD, attrValuesPath, attrValues) != 0)
{
Console.WriteLine("GetObjectAttributesEx Failed.");
GetErrors(session);
return;
}
else
Console.WriteLine("Retrieved Category Version.");

//Finally, we can create the document

//create the output variable objectInfo, which will contain the object's information
LLValue objectInfo = (new LLValue()).setAssocNotSet();

//Setup any information for creation
LLValue createInfo = (new LLValue()).setAssocNotSet();
LLValue request = (new LLValue()).setAssocNotSet();
request.add("Comment", "These are the document's comments.");
createInfo.add("request", request);

//Create the list of categories for the document
LLValue categories = (new LLValue()).setList();
categories.add(catVersion);

//Add the list of categories to the createInfo
createInfo.add("Categories", categories);

//Create the document object in Livelink
if(doc.CreateObjectEx(volumeID, dataID, LAPI_DOCUMENTS.OBJECTTYPE, LAPI_DOCUMENTS.DOCUMENTSUBTYPE, "LivelinkTest2", createInfo, objectInfo) != 0)
{
//// THE ERROR OCCURS HERE ////
GetErrors(session);
return;
}
else
Console.WriteLine("Document Object Created.");

//create the output variable versionInfo, which will contain the version's information
LLValue versionInfo = (new LLValue()).setAssocNotSet();

//Add a version to the document object
if(doc.CreateVersion(volumeID, objectInfo.toInteger("ID"), @"D:\LivelinkTest2.txt", versionInfo) != 0)
{
GetErrors(session);
return;
}
else
Console.WriteLine("Version Created.");
}

 
Thanks. I found the problem...

For VolumeID I used volumeID = pwsInfo.toInteger("ID");
instead of pwsInfo.toInteger("VolumeID");

Ciao
 
also fYI the code that Greg pointed out actually shows you how to make a category object not applying it to a container/document.I wrote it several years back when I was trying to learn the sample given in lapi documentation,so don't really know it will work in the modern day age

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
the communities website has a lot of useful postings.How is the use on your site nowadays Greg.I am currently doing a stint with vb.net and lapi I think I should be able to send you some stuff it starts off with connection,creation of a folder,add a category and add a document.

This client is a vb.net junkie so I am learning that

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

Part and Inventory Search

Sponsor

Back
Top