Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Content Management (Extended ECM)
API, SDK, REST and Web Services
Update existing STRPOPUP values
David_Benjamin
I've been trying to update an existing attribute's values. I do the following Value API:LLValue vCatID = (new LLValue()).setAssocNotSet();LLValue vCatVersion = (new LLValue()).setAssocNotSet();LLValue vAttrInfo = (new LLValue()).setAssocNotSet();vCatID.add("ID", objECMItem.getICategoryID());iReturnVal = documents.FetchCategoryVersion(vCatID, vCatVersion);LLValue vAttrVals = (new LLValue()).setList();while(itrVals.hasNext()){ strAttrValue = lstAttrValues.get(j).toString(); vAttrVals.add(strAttrValue); j++; itrVals.next();}I've tried updating the values using this:int iAttrType = attributes.ATTR_DATAVALUES;iReturnVal = attributes.AttrSetValues(vCatVersion, objECMItem.getStrAttributeName(), iAttrType, null, vAttrVals);and this:iReturnVal = attributes.AttrGetInfo(vCatVersion , objECMItem.getStrAttributeName(), null, vAttrInfo);vAttrInfo.setValue("ValidValues", vAttrVals);iReturnVal = attributes.AttrSet(attrInfo.getStrName(), vAttrInfo, null, vCatVersion);Neither of the above methods seem to do anything. The attribute values remain the same. I'm obviously missing a step somewhere.Can anyone help? Thanks.
Find more posts tagged with
Comments
Carsten_Kulms
Message from Carsten Kulms via eLinkI think the final SetObjectAttributesEx call is missing. With thatfunction the changes made to the (local) catversion are transferred tothe server and applied to an object's attributes.You may like to look at the example code attached to(If I remember correctly it does not cover the STRPOPUP case but maybeit is still useful.)
David_Benjamin
I am not trying to update the values on an object. I am trying to update the attribute values in the attribute definition. The equivalent of going to the Admin Page and adding a value to a dropdown and clicking Update.
Appu_Nair
in the online lapi documentation there existed a sample for that which was at best confusing.So way back I cut & pasted that sampleand made it work(well almost 100 %).This could be found under this link.
http://www.greggriffiths.org/livelink/development/lapi/
the link calledCategories & Attributes.
Carsten_Kulms
Message from Carsten Kulms via eLinkThen a new category version is to be created by means of theCreateCategoryVersion function.----8<--------8<--------8<--------8<----Using Categories and AttributesLAPI provides functions that allow you to create and maintain LivelinkCategories and Attributes. A Livelink Category is a versioned object.Category objects can be created in any Livelink container such asFolders, Projects, or Workspaces. Each time you create or modify aCategory, you must add a version to the Category object. Categoryversions contain Attribute definitions.[....]Category MaintenanceThe following describes general Category tasks:Modify existing Category versions. If you want to modify a Category version, you must retrieve it from theCategory object on the Livelink server using the FetchCategoryVersionfunction. Each Category version contains a unique identifier called thecatID for that Category version. After manipulating the Category version(using calls to the Attributes API functions), you update the Categoryby adding a new version to it by calling the CreateCategoryVersionfunction. [...]----8=--------8=--------8=--------8=----[Livelink API Developer's Reference - Category and Attribute Support]You may also like to have a look at the UpgradeCategoryReferences andUpgradeObjectCategory functions.
David_Benjamin
Thanks for the feedback.Appu's example is for creating new category and new attribute so it doesn't apply to what I'm trying to do.I added the CreateCategoryVersion call after using AttrSetValues to update the attribute values but the changes still did not take.Here's what I tried:1. Called FetchCategoryVersion2. Created an LLValue of type List using (new LLValue()).setList()3. Added the updated values to the LLValue list4. Called AttrSetValues using the Cat Version from step 15. Called CreateCategoryVersion using a new Cat Version LLValueA new category version was created but the attribute values were not updated.I also tried the above passing the same Cat Version I got from step 1 in the CreateCategoryVersion which threw an error as I expected it would.I also tried:1. Called FetchCategoryVersion2. Created an LLValue of type List using (new LLValue()).setList()3. Added the updated values to the LLValue list4. Called AttrInitCatVersion5. Called AttrSetValues using the Cat Version from step 55. Called CreateCategoryVersion using a Cat Version from step 5This approach also threw an error on the CreateCategoryVersion call.Is there documentation or sample code somewhere that illustrates how to update an existing attribute's values? The LAPI documentation hints at how to do something but doesn't really give you the whole picture.Thanks.
Carsten_Kulms
Message from Carsten Kulms via eLinkNot sure if I understand correctly but I think there is amisunderstanding."Categories are versionable items, which means that Livelink canmaintain multiple Versions of a Category. Any time you modify a Categoryand save those changes, Livelink creates a new Version of the Category.Existing items continue to use older Versions while new items use themost recent Version. This allows you to change the attributes in aCategory at any time without invalidating the attribute data of existingitems.Because a new Category Version does not affect existing itemsautomatically, you must manually upgrade an item's Category assignmentto apply the newest Version of the Category to the item. Whenever aCategory is modified, the Upgradable icon Upgradeable icon displays onthe Categories Properties tab of every item that is associated with thatCategory. This indicates that you may upgrade the item's Categoryassignment."That means: Once you have update the attribute definitions, i.e. createda new category version, you will be able to assign the new attributes /values to objects. Either to a new object by assigning the category (themost recent version) or by upgrading the objects to which the categorywas already assigned (but the previous version).Simply changing the attribute definitions does not alter the metadata ofthe object the category is assigned to.
David_Benjamin
Thanks for the response. I know that categories have versions. The issue is after creating the new category version using CreateCategoryVersion the new attribute values I set using AttrSetValues are not there in the new category version.I've attached the java code I'm using to get and set attribute values. If you don't mind can you take a look and see if I'm doing anything wrong?Thanks.
Appu_Nair
Just a hunch I cannot test this but this is suspiciousiReturnVal = attributes.AttrSetValues(vCatVersion, objECMItem.getStrAttributeName(), iAttrType, null, vAttrVals);You seem to me manipulating vCatVersionbut then you seem to be doing thisiReturnVal = documents.CreateCategoryVersion(vCatID, vNewCatVersion);where vNewCatVersion is just an initialized variable.How does VnewCatVersion that has your changes get sent to LES ?
David_Benjamin
Right, I thought I had it figured out. I was not initializing a new category version and also using AttrSetValues instead of AttrSet. The new code is attached.But now I'm getting "com.opentext.api.LLIllegalOperationException: get(name) not implemented for this datatype" when I make the AttrSet call. Not sure what that means.Any ideas why I'm getting that error?Thanks for both of your help on this. The documentation is not exactly the best.
Appu_Nair
I really wish I could debug your code.But let me ask you a simple requiremnt qn.You have an existing category object that has a string popup with three values "one","two","three".Your aim is to create a ctegory version with "one","two","three","four" something like that.Is my inference correct.psuedo code for this would beGet existing catversion.That would contain "one","two","three" in its datastructure.Manipulate this and add "four".At this point the datastructure is in the client.Create CategoryVersion with this or you are sending the revised version to lES.getName errors means that the preceding call did not complete as intended and you are trying to print something thinking that it would be successful.If nobody else takes a look I will try to rig up a C# sample in my spare time if that is what you are trying to do.
Carsten_Kulms
Message from Carsten Kulms via eLinkSorry, due to missing time only some hints:The "LLIllegalOperationException: get(name) ..." error usually indicatesa severe problem at the server side. You can find some more detailsabout this error in this discussion. Basically it boils down to:- enable "Detailed Thread Logging" at the server- run your test- checks the server logs, especially for trace...out filesAlternatively you may step through the call in LLBuilder.Attached a Java sample for CreateCategroyVersion -- incomplete as itdoes not modify anything but this may serve as basis for furtherevaluations.
David_Benjamin
We're coding web services to allow our clients to manipulate objects in Livelink without having to do the LAPI themselves. For this method they will be able to update the values in a string popup. They'll pass in the attribute name and a list of values to populate the drop-down with. I'm trying to take that list of values and replace what currently exists.You say Manipulate this and add "four". What I'm doing is looping through the values passed into the method and adding them to a List LLValue object, taking that List LLValue object and adding it to an LLValue object as "ValidVals" and passing that as the AttrInfo parameter of the AttrSet method. Since it's not working my guess is that's not the correct thing to do. What do you mean when you say manipulate this and add "four"? How would you go about doing that?Thanks.
Appu_Nair
Yes validvals is thelist and in my example "one","two","three"In the revised catversion the validvals will be a revised list consisting of{"one","two","three","four"}.There are other possibilities to a category like you can repeat the rows etc.Now the real question is like Carsten said having done all these you would still need to "upgrade Objects" showing this new category.I hope you are able to understand what Carsten is saying about just putting a new version won't show your new values on documents,folders etc until and unless they are upgraded as well.I still think you are very close it might be just a small bit that you are missing.LAPI documentation is not the best and as I and Carsten can vouch sometimes I look at builder to see what is going on and that helps a lot.
Appu_Nair
BTW is there a reason why you are not using true web services are you not on LES9.7.1 ?
David_Benjamin
I know about the upgrade for existing documents that have the category already attached. We're currently on 9.5 not 9.7 but hope to get there sometime this year.Thanks for all the help.
Carsten_Kulms
Message from Carsten Kulms via eLinkAttached the example tool extend by an example modification--allhardcoded, as a general functionality would require more time. The category this works with must have an attribute of type "text:popup", named "textpopup" at the topmost level (not a set attribute).Hope that helps.> object and adding it to an LLValue object as "ValidVals" and > passing that as the AttrInfo parameter of the AttrSet method. Maybe that's it: The name is "ValidValues" (at least in 9.7.1).
David_Benjamin
Carsten,Thank you very much for taking the time to put this example together for me. My biggest question is...Without your help how would someone figure out the line of code below? How did you know to add that line?catId.add("Type", LAPI_ATTRSERVER.CATEGORY_TYPE_LIBRARY);Thanks.
Carsten_Kulms
Message from Carsten Kulms via eLinkI do not remember how/why ... if you look a the documentaion ofFetchCategoryVersion and other functions with "catID" parameter, thedescription of "catID" is linked to details about this Assoc. There"Type" is mentioned. As I see now the line may be superfluous because"An implementation type constant that designates the kind of categoryattributes implementation. The default value is CATEGORY_TYPE_LIBRARY."
Appu_Nair
Perhaps I should have kept quiet but I see none of the other lapie'rs livelinkers looking at this thread.I am seeing a great benefit to you in this regard using "attribute extensions" module which would have allowed you to run sql to get the valid vals from a table that you populate/edit/modify etc,This would mean that you are not changing "category versions" thru code as well.Perhaps you may have reasons to hard code the list like you do but do understand that there is an useful module out there for this .Typically the SQL can be as easily inserted by use of a livelink html web form.