I am using alfresco webscript to get the list of versions for a document
when i try to get the noderef of a all version using the property
child[i].noderef
as mentioned in below link:-
ScriptNode API | Alfresco Documentation
i get all versions node id as same
Please tell if the noderef is same for all versions
or if there is a way to get unique noderef of each version.
Solved! Go to Solution.
The nodeRef is the same because you are getting it from the document (children[i]) instead of the version.
Use docVersions[v].node.nodeRef instead
Update: Sorry - it was late and I got confused by your use of children[i] within the loop. Replaced children[i].node.nodeRef with docVersions[v].node.nodeRef
Each node in Alfresco and each version have a unique NodeRef. This is enforced on a DB constraint level and cannot be circumvented. Though there are features that masquerade the underlying NodeRef, e.g. when using multi-tenancy where it is technically possible for two tenants to have nodes with identical NodeRefs. But these identical NodeRefs are only identical on a logical level - in the underyling DB layer they are again unique.
Using js webscript how to get the unique noderef for each version of a document ?
The documentation on Script API for versions should help you get started...
Hi, Anuj
You can get the all versions of a document using this api url,
http://serverort/alfresco/service/api/version?nodeRef=workspace://SpacesStore/09d0c872-3f0a-49df-91f...
You will get the output in JSON format.
Axel Faust Vikash Patel
hi,
i am able to get the documents versions .
My question is simply :- At DB level we are having unique noderef for a document version.
but when i do child[i].nodeRef , i get same noderef for all versions
is there some property other than 'noderef' which can give unique node reference.( i am referring to properties like in this documentation -------> ScriptNode API | Alfresco Documentation
Thanks
I seriously don't know what you are trying to access "child[i].nodeRef" for - and I don't know what values you have assigned to it. Via the ScriptNode getVersionHistory() operation you get a list of versions, and each version will have a "version.frozenStateNodeRef" property.
The nodeRef is the same because you are getting it from the document (children[i]) instead of the version.
Use docVersions[v].node.nodeRef instead
Update: Sorry - it was late and I got confused by your use of children[i] within the loop. Replaced children[i].node.nodeRef with docVersions[v].node.nodeRef
on using this ,
i get this error
org.alfresco.error.AlfrescoRuntimeException - 01010316 TypeError: Cannot read property "nodeRef" from undefined
this is exactly what i needed !!!!
Thank you
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.