cancel
Showing results for 
Search instead for 
Did you mean: 

How to get NodeRef of a document using javascript

sbsrulz
Champ in-the-making
Champ in-the-making
Hi,

I would like to write a JavaScript that associates a file with some already existing document in the repository as soon as the file is uploaded. I know I can use the createAssociation function but I have some trouble getting the nodeRef for the documents. So my question is:

How can I get the NodeRef for already uploaded document and the file being uploaded using JavaScript?

Thanks,
SbS
4 REPLIES 4

mikeh
Star Contributor
Star Contributor
That depends on how you want to find the document in order to get it's nodeRef.

Check out the JavaScript API here: http://wiki.alfresco.com/wiki/JavaScript_API_For_Alfresco_2.1
…and also the Cookbook with a number of examples here: http://wiki.alfresco.com/wiki/JavaScript_API_Cookbook

You can also browse through "out of the box" JavaScript code by starting from http://<server>/alfresco/service/index

Thanks,
Mike

sbsrulz
Champ in-the-making
Champ in-the-making
I have been through the examples but I couldn't sort out my prob. Here's my scenario:

I have a custom content type of 'customer form' that the admin uploads to a space. The customer's signature files (images) are uploaded to a separate space. Now I want the customer's form to be associated automatically with his signature file as soon as the customer's form are uploaded. I have the types defined and can do all this in the web client but I want to use Javascript to handle this situation.

I was trying to use CreateAssociation() but I need nodeRef or ScriptNode in order to refer to the customer's form and their signature files. How can I get that?

A little elaboration would be helpful…

mikeh
Star Contributor
Star Contributor
You need to do a search for the customer's signature file and you'd obtain the nodeRef from that. Depends what you've got to search on: name, folder, etc.

e.g. search.luceneSearch("+@cm\\:name:" + customer)

Mike

sbsrulz
Champ in-the-making
Champ in-the-making
Thanks Mike… Got it Smiley Happy