Hallo
Thank for your example, it's very usefull to learn OScript.
But i have the same Prolbem as originally in this post. At the moment, i have yet a DAPINODE myNode and i want to read (and write) the Attributs of this node. I can not find a function to do this.
Can you give me any additional hint about this? (even it's very simple for you ;-) )
(in a next step i need to find a node with a given Attribute Value. What's the best approach for that? I think, finding the objectId directly in the DB by SQL would be the fastest, but where are the Attribut Values Stored (and "linked" to DTree)? I can only find the Category Definition in the CatRegionMap Table. Or do you think, there is also a fast way using OScript for that too?)
Thomas
For retrieving the data of an attribute use the function LLNode.NodeCategoriesGet
For getting th edefinition of a Categor if you have the DataID of the Category object use $LLIAPI.AttrUtil.ArtrDefGet.
The NodeCategoriesGet function also returns the category definition of the categories invovled. The difficult part of handling categorie is that the definition and attributes values
Are in separate Assoc fields, so you need to travel both to get/set the value of a specific attribute.
Hans
From: eLink Entry: Content Server Development Forum [mailto:development@elinkkc.opentext.com] Sent: Freitag, 13. August 2010 11:43To: eLink RecipientSubject: Set Category to Folder & Subfolder Using OScript
Set Category to Folder & Subfolder Using OScript
Posted by theusser (Heusser, Thomas) On 2010/08/13 05:41
But i have the same Prolbem as originally in this post. At the moment, i have a DAPINODE myNode and i want to read (and write) the Attributs of this node. I can not find a function to do this.
[To post a comment, use the normal reply function]
Topic:
Forum:
Content Server Development Forum
Livelink Server:
knowledge-wlweb01
Hi Hans,
thanks a lot, i tried that too, but without succes, this is the Output (so it's the correct node, but i can not get the Category of it)
parentnode; U<DAPINode(-72)=0231A420> partentnode.pId: 4641 parentnode.pName: TestFolder_TestCategoryRoot cat(==$LLIApi.LLNode.NodeCategoriesGet(parentnode)): A<1,?,'ApiError'=?,'AttrData'=?,'ErrMsg'='The \'TestFolder_TestCategoryRoot\' cannot have categories.','OK'=false>
This 'TestFolder_TestCategoryRoot 4641 has the Categroies i want to retrieve, but i get the above ErrMsg.
Is there any info available on this?
Furthermore after studing some more threads here i think, i should get my resutl with something like f.DBGet(), where f is something linke Frame f = $LLIAPI.AttrData.New( prgCtx, parentId, 0 ).
But also with this apporach i do not get yet any usable result... (error here: "Cannot get value; a non-existent featre was specified"). May be, here the problem is the 3rd param (verNum) but also here i do not know yet, how to get the last version, because i have only one version i tried 0 and 1, but with the same error.
Do you have any hint, which is the right approach or what could be my problem ...?
I realy read a lot of threads here and documentations, but i only found several times the same (or similar) question but no answer which helped me further
to sumarize my needs:
a) get Attributs of a given Node (in my case Folders) b) set other Attributes of the same Node c) find Nodes (Folders) with a given Attribut Value (there i think to use SQL on LLAttrData, or is there also some (fast) OScript Function for that?)
Thanks for any hint
Hallo,
is spend some more hours on that and i've seen, that we are speaking about different things.
Your functions works fine on a Category Node.
But i have my problems on a Folder Node, so the new Problem is, how to find out, which Categories are used on a Folder.
I get a Result with lliapi.AttrData.New( prgCtx, folderId, <version num> )
BUT How do i know the version <version num>? If i hardcode the Version Number (at the moment 0) than it's fine, but does not work in the future.
Am i on a wrong way ...??? I think, it's quite basic to get an Attributs of a Folder, so i expect, there is a function, but i can't find it ... - or do i need several lines of code for that?
Kind regards
Hello,
To add category to a node you should to as follows ( i took some lines from my existing code, hope it works)
i created a small function. Input params: program context, node id, category id
function AddCategory( Object prgCtx, Integer nodeID, categoryID )
// Get DPINODE by node id DAPINODE targetNode = DAPI.GetNodeByID( prgCtx.DapiSess(), DAPI.BY_DATAID, nodeID ) //Get object llnode Object objllnode = $LLIApi.LLNodeSubsystem.GetItem( targetNode.pSubType )
//Get node category info Dynamic originalCatResult = objllnode.NodeCategoriesGet( targetNode ) //get nodecategory attributedata Dynamic attrData = originalCatResult.AttrData
//Add desired category info to attrdata Dynamic result = attrData.AttrGroupAdd( categoryID )
//Update node category info Dynamic dyn = objllnode.NodeCategoriesUpdate( targetNode, attrData )
end
regards,
keit
I know how to work with Cats&Atts with LAPI only; I did not need to handle them in OScript yet. But if I had to, I would look at the LAPI calls and "steal" the code from there. Reading is usually done by calling ListObjectCategoryIDs -> GetObjectAttributesEx and writing by FetchCategoryVersion -> SetObjectAttributesEx. The LAPI calls are documents in the SDK.
--- Ferda
thanks for your feedback! Now i have finally the first Task of reading Attributs. I can't believe this is the way to do it, but with about 20 Lines of Code, it works finaly ....
Now i thougt, the second task to set Values is "about the same"
In AttrData i found those functions:
public final Assoc ValueGet( List spec ) public final Assoc ValueSet( List spec, Dynamic value )
But of corse it does not yet work ... ;-(
At least, i expect the spec to be the same for ValueGet and ValueSet - can someone confirm this? (in my case it's something like {17347,3}. 17347 is the ID, but i do not yet know, what the second param is
Now the next question is, what ist the value to pass. I allways got "There is a error in the argument list"
I tried the following:
a) the I use the result from valueGet() as value for the valueSet (i expect this to work, but it does not)
all the following are wild guess, without success
b) i use the feature .value of the ValueGet() result -> same error c) i use ASSOC with AttributName / AttributValue -> same error
can someone point me to the right way or any documentation?
I tried also to follow Ferdinand's way, but what are those EX-Functions? Where do i get some Infos about them (Syntax, Documentation, what ever ...)
If you want to take the rouh way, LAPI calls handling the Cats&Atts are in the OSpace APIDOC under the object APIDocuments. Keit's approach is probably better - to look at methods in the OSpace LLIAPI in the object LLNode and pick some with names indicationg what you want. Then you can search all OSpaces who uses them and how.
Most of us use the link that Greg pointed to you involves the frame and the whole nine yards.For my benefit and for the benefit of my other colleaugues I created a simple function
https://knowledge.opentext.com/knowledge/llisapi.dll?func=ll&objId=17996016&objAction=download
I have included how to use it in the function.Give it a look and adapt for your work.
The second number is the category version { catid, catversion }
attrData._FindEntry will tell you what is required by ValueSet
{ { 2343, 4 }, { 1, 1, 2, 1 } }
Hi,
To set value for attribute i use logics like this:
1. get node categories info, it gives you frame. Containing definitions and values Assoc
2. To set attribute value you should loop over the value assoc find the right list, set value (attribute value is list)
3. Save attributes
See attachment for key oscript phrases.
For my own i have created so called tools collection. There i have such function like
SetCatAttributeValueByIDCatID, SetCatAttributeValueByAttrName, GetCatAttributeValueByName, SetCatAttributeValueByIDCatID, etc.
thanks a lot all of you, first of all Appu! I have now a running function and i'm able to addapt it. Furthermore
- i learn a lot about using OScript- i feel saver, that this is the way to do it (i really did not expect, that such "basic" functionallity needs 150 Lines of code done by each developper individually ....)
I tried to implement this procedure for add a category to a folder but when it excute the line: Dynamic result = attrData.AttrGroupAdd( categoryID )it gives the error "Error retrieving the version of the attribute definition node."I tried also in this way: Dynamic result = attrData.AttrGroupAdd( categoryID )
But it gives the same error, please could you help me?
Hi Fabrizio,
What happens when you do the same in the CS Web UI? Do you get the same error?
Normally the error means that you didn’t define the category yet, you only have created it.
To solve it you need to click on the category name and save it.
From: eLink Entry: Content Server Development Forum [mailto:development@elinkkc.opentext.com]Sent: Donnerstag, 8. September 2016 16:16To: eLink RecipientSubject: RE Set Category to Folder & Subfolder Using OScript 2
RE Set Category to Folder & Subfolder Using OScript 2
Posted by Menichelli, Fabrizio On 09/08/2016 10:13 AM
Quoted Keit Kivisild on 09/08/2016 04:13 PM:
Content Server:
Knowledge Center
Thank you Hans,via web interface it's ok
I tried to help with this in your other post hopefully you are out of the woods
https://knowledge.opentext.com/knowledge/cs.dll/open/63900247
It is something I quickly made up from my old code many yearsback