10-02-2018 07:58 AM
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.
10-02-2018 09:31 PM
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?
10-03-2018 03:54 AM
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).
10-03-2018 09:41 PM
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();
10-22-2018 06:45 AM
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.
Explore our Alfresco products with the links below. Use labels to filter content by product module.