Each document version has unique noderef or not ?

cancel
Showing results for 
Search instead for 
Did you mean: 
anujsharma
Active Member II

Each document version has unique noderef or not ?

Jump to solution

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.

1 Solution

Accepted Solutions
afaust
Master

Re: Each document version has unique noderef or not ?

Jump 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

View solution in original post

9 Replies
afaust
Master

Re: Each document version has unique noderef or not ?

Jump to solution

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.

anujsharma
Active Member II

Re: Each document version has unique noderef or not ?

Jump to solution

Using js webscript how to get the unique noderef for each version of a document ?

afaust
Master

Re: Each document version has unique noderef or not ?

Jump to solution

The documentation on Script API for versions should help you get started...

vikash_patel
Established Member

Re: Each document version has unique noderef or not ?

Jump to solution

Hi, Anuj
You can get the all versions of a document using this api url,
http://serverSmiley Tongueort/alfresco/service/api/version?nodeRef=workspace://SpacesStore/09d0c872-3f0a-49df-91f...
You will get the output in JSON format.

anujsharma
Active Member II

Re: Each document version has unique noderef or not ?

Jump to solution

Axel FaustVikash 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

afaust
Master

Re: Each document version has unique noderef or not ?

Jump to solution

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.

afaust
Master

Re: Each document version has unique noderef or not ?

Jump 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

anujsharma
Active Member II

Re: Each document version has unique noderef or not ?

Jump to solution

on using this ,

i get this error

org.alfresco.error.AlfrescoRuntimeException - 01010316 TypeError: Cannot read property "nodeRef" from undefined

anujsharma
Active Member II

Re: Each document version has unique noderef or not ?

Jump to solution

this is exactly what i needed !!!!

Thank you Smiley Happy