cancel
Showing results for 
Search instead for 
Did you mean: 

Paste as Link script

johanpi
Champ in-the-making
Champ in-the-making
Is their any javascript available to Paste content as a Link from a javascript? I created an upload form using .ftl and .js. I need to create a link in another space when uploading the content.
Sample: I have a department with meeting minutes space. The company wants to have all meeting minutes available in one space. I want to load to the department, but link to common space.
Thanks
7 REPLIES 7

rdanner
Champ in-the-making
Champ in-the-making
I know this post is very old – perhaps you have figured it out.  Maybe someone else will need this information as well.

One way to do it is just create the link yourself like such:



var vTarget = companyhome.childByNamePath("PATH TO TARGET HERE');

if(vTarget != undefined)
{
   var vLinkFolder = companyhome.childByNamePath("PATH TO DESTINATION HERE");
   
   if(vLinkFolder != undefined)
   {
                var vLinkName = "Link to " + vTarget.name;
      var vLink = vLinkFolder.createNode(vLinkName+".url", "app:filelink");
      
      vLink.properties.content = "";
      vLink.properties.content.mimetype = "UTF-8";
      vLink.properties.title = vLinkName;
      vLink.properties.description = vLinkName;
      vLink.properties.destination = vTarget;
      vLink.save();
   }
}

-R

pawan_gandhi
Champ in-the-making
Champ in-the-making
Could any one please help me in this functionality.

Thanks

lista
Star Contributor
Star Contributor
I'm sure there's people willing to help you, but you need to describe your problem a bit better.
Be as detailed as possible, give us code snippets and so on.

johanpi
Champ in-the-making
Champ in-the-making
The previous post have errors. I fixed this to create link between folders. To test I created a script then ran an action (execute a script) against some content.

I will see if I can get content links to work

var vSourceFolder = companyhome.childByNamePath("Sites/ECM");  //space/folder where link is generated from

if(vSourceFolder != undefined)
{
   var vLinkFolder = companyhome.childByNamePath("Projects/ECM");  //target folder - linked folder in this space to Source Folder Space
  
   if(vLinkFolder != undefined)
   {
      var vLinkName = "Link to " + vSourceFolder.name;

      var vLink = vLinkFolder.createNode(vLinkName+".url", "app:folderlink");
     
      vLink.properties.content = "";
      vLink.properties.content.mimetype = "UTF-8";
      vLink.properties.title = vLinkName;
      vLink.properties.description = vLinkName;
      vLink.properties.destination = vSourceFolder;
      vLink.save();
   }
}

johanpi
Champ in-the-making
Champ in-the-making
The code to create link for content. (Could someone tell me how to create a "code box" to copy the code in and make it selectable in this browser)

var vSourceFolder = companyhome.childByNamePath("Sites/ECM");  //space/folder where link is generated from

if(vSourceFolder != undefined)
{
   var vLinkFolder = companyhome.childByNamePath("Projects/ECM");  //target folder - linked content in this space to Source Folder Space
  
   if(vLinkFolder != undefined)
   {
      var vLinkName = "Link to " + document.name + ".url";
      var vLink = vLinkFolder.createNode(vLinkName, "app:filelink");

      vLink.properties.title = "Link to " + document.name;
      vLink.properties.description = "Link to " + document.name;
      vLink.properties.destination =  vSourceFolder.childByNamePath(document.name);
      vLink.save();
    }
}

pawan_gandhi
Champ in-the-making
Champ in-the-making
I want to create link to contents, i am very new to alfresco. Currently i know that this code shown in this post is related to web scripts, but how to use it, i dont know. Could any one tell me in detail that how to execute it.

My target is that i need a kind of symbolic link to an artifact using two links. Like i have an artifact (say jar file) in dev folder (CompanyHome/Software/Dev) and i need to browse or access it (using wget) using two different urls. Can i do it using this code or any other idea is most welcome.

Thanks in advance.

Sincerely,
Pawan

luxoliver
Champ in-the-making
Champ in-the-making
Hi,

Maybe you should have to take a look here : http://wiki.alfresco.com/wiki/Web_Scripts