Paul
Paul

Reputation: 141

Alfresco : How can I get file from Sites/test/documentLibrary dynamically?

I am uploading an Alfresco file, I need get the file from documentLibrary dynamically, how can I do this? .bpm20.xml is possible.

 var dest= companyhome.childByNamePath("Sites/test/documentLibrary/"+${trainername});
     bpm_package.addNode(dest);

Please help out

Upvotes: 0

Views: 274

Answers (1)

kinjelom
kinjelom

Reputation: 6450

The companyhome is one of root objects, class org.alfresco.repo.jscript.ScriptNode.

Method ScriptNode.childByNamePath(String path) returns another ScriptNode.

To get file name you can use ScriptNode.getName() method (Java or JavaScript) or name property (shortcut access to the cm:name property) in JavaScript.

var dest= companyhome.childByNamePath("Sites/test/documentLibrary/"+${trainername});
bpm_package.addNode(dest);
logger.info("and the file name is.... "+dest.name);

Is that answers your question?

BTW: "What's the difference between JavaScript and Java?"

Upvotes: 2

Related Questions