cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript function to get alfresco document by noderef id?

benvercammen
Champ in-the-making
Champ in-the-making
Hi, I'm beginning to get the feeling this may not be the best forum to post questions about writing custom views in FTL's, but I couldn't find one that's more related. So if this question is in the wrong forum, please let me know!

Now for my question… I would like to know if it's somehow possible to get a handle for an "alfresco document" within a javascript. What I'm looking for is some kind of javascript function that I can call with the nodeRef ID of the document I need, and then get the document object returned to me…

To clarify:

function doSomethingWithADocumentInsideACustomViewFTL(DOCUMENT_NODEREF_ID) {
    var alfresco_doc = SomeKindOf.magical_function.which_returns_the_document(“/alfresco/navigate/showDocDetails/workspace/SpacesStore/DOCUMENT_NODEREF_ID”);
    var name = alfresco_doc.name;
    var some_property = alfresco_doc.properties.some_property;
    …
}

Am I looking for something non-existant or going at this the wrong way? Or am I actually making sense and can someone give me that "magical_function"?
3 REPLIES 3

benvercammen
Champ in-the-making
Champ in-the-making
Okay, I've already found a (workaround) solution to my problem (however I'd still like an answer on the original question). I was already using an AJAX call to do something to the document, and I forgot that I could just return the single value that I'd need.


var url = '/alfresco/command/script/execute/workspace/SpacesStore/SCRIPT_ID/workspace/SpacesStore/' + documentID;
YAHOO.util.Connect.asyncRequest('GET', url,{
   success: function(o) {
            //the text I need to change is inside a span with id = documentID…
            document.getElementById(documentID).innerHTML= o.responseText;
   }
});

Is there perhaps a way to return the entire document? It wouldn't be as clean as that "magical_function" I'm looking for, but at the moment it does the job for me…

roger16
Champ in-the-making
Champ in-the-making
Hi did you find any solution for this one? I have the exact same requirement.

abarisone
Star Contributor
Star Contributor
Hi,
you can find a node by nodeRef using the Search API as reported here http://wiki.alfresco.com/wiki/4.0_JavaScript_API#Search_API
Pay particular attention to the findNode method which comes with a lot of different signatures.
You can find the variant that suits for you.

Regards,
Andrea