Hi all.
in 5.2 how can i create a link to a document (or a folder) that when i delete the source node, it will also be deleted.
I have seen
https://community.alfresco.com/thread/149153-create-a-link-to-a-node-file-or-folder#comment-617799
and DocumentLinkServiceImpl.java
but i cannot complete such a task.
Thank you in advance.
What you are describing is the out-of-the-box behavior for links in Alfresco. If you create a document, then do a Copy, you can choose "Create Link" when you pick the destination.
If you then go delete the original document, the link is also deleted.
Is this the functionality you are looking for or is it something different?
yes this functionallity we want to reproduce using javascript.
if we use:
var pr = [];
pr["cm:name"] = "targetName.jpg.url";
pr["cm:destination"] = "workspace://SpacesStore/76c17fe2-93f9-4293-a989-e50c4c1e01e4"; (Alfresco Target Node Reference)
pr["cm:title"] = "targetName.jpg";
pr["cm:description"] = "targetName.jpg";
linkNode = space.createNode("targetName.jpg.url", "{http://www.alfresco.org/model/application/1.0}filelink", pr);
linkNode.save();
as suggested in a previous post, the assosiasion is not created, add the aspect ASPECT_LINKED is not added to the target node (while enabling and dissabling the ContentModel.ASPECT_AUDITABLE behaviour).
You can add the linked aspect yourself. So, taking your code, and adding a couple of variables for the doc and the space, this works:
var doc = search.findNode("workspace://SpacesStore/af65018d-dabb-4a83-ac22-007dd99ff361");
var space = search.findNode("workspace://SpacesStore/6513e985-ce14-4002-bee9-0a60279f44b0");
var pr = [];
pr["cm:name"] = "test1.txt.url";
pr["cm:destination"] = doc.nodeRef.toString();
pr["cm:title"] = "test1.txt";
pr["cm:description"] = "test1.txt";
linkNode = space.createNode("test1.txt.url", "{http://www.alfresco.org/model/application/1.0}filelink", pr);
linkNode.save();
doc.addAspect("app:linked");
doc.save();
Noticed that when creating links with the above code, i get the warning:
WARN [web.scripts.ActionEvaluatorHelper] Evaluator 'null' not found.
when I browse to the folder that the link exists. Any ideas why?
Edit: ok, the above warning i am getting also when i create the link from share interface.
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.