1

I need help populating dropdown list in Alfresco Share. I've created a WebScript API which I read the content of a folder in the repository. As a service in Alfresco (repository) it works. However, I need that DropDown in Share.

Here is what I did in Alfresco:

var folder = roothome.childByNamePath(url.extension);
if (folder == undefined || !folder.isContainer)
{
   status.code = 404;
   status.message = "Folder " + url.extension + " not found.";
   status.redirect = true;
 }
 model.folder = folder;
<webscript>
  <shortname>Folder Listing Sample</shortname>
  <description>Sample demonstrating the listing of folder contents</description>
  <url>/folder/{path}</url>
  <format default="html">argument</format>
  <authentication>user</authentication>
  <transaction>required</transaction>
</webscript>
<html>
  <head>
    <title>${folder.displayPath}/${folder.name}</title>
  </head>
  <body>
    Folder: ${folder.displayPath}/${folder.name}
    <br>
    <select id='selectItems' name='selectItems' onchange='dropdown2()'>
        <#list folder.children as child>
            <option value='${child.nodeRef}'>${child.properties.name}</option>
        </#list>
    </select>
  </body>
</html>
<#macro encodepath node><#if node.parent?exists><@encodepath node=node.parent/>/${node.name?url}</#if></#macro>

I need this dropdown in Share. Since variables like: userhome, companyhome and such aren't accessible from Share WebScripts, I don't know how to get info from Alfresco and display it in Share. Any help would be appreciated.

Miki
  • 2,493
  • 2
  • 27
  • 39
The Macedon
  • 199
  • 2
  • 12
  • maybe this could help you -> http://stackoverflow.com/questions/17150808/dynamic-selectone-in-alfresco-share – Miki Oct 16 '14 at 07:34
  • Is your question just how to get the company home and user home nodes in Share server-side javascript? Or something else? – Gagravarr Oct 16 '14 at 08:41

1 Answers1

2

From javascript controller of alfresco share, you can call webscript of alfresco and retrieve details from alfresco webscript in json format. Below is one example which is calling alfresco side webscript from share javascript controller.

 try
 {

  var url = "/slingshot/webscript/from/alfresco/url";
  logger.log("url: " + url);
  // Request the current user's preferences
  var result = remote.call(url);
  if (result.status == 200 && result != "{}")
  {
     logger.log(result);
     var nodeInfo = eval('(' + result + ')');
     nodeRef = nodeInfo.parent.nodeRef;
  }
 }
 catch (e)
 {    }

In above url, is of alfresco webscript url which will return data in json format.you can also return data in another format depends on your requirement.

Miki
  • 2,493
  • 2
  • 27
  • 39
Krutik Jayswal
  • 3,165
  • 1
  • 15
  • 38
  • While we are on the subject, I managed to do this. Thanks, but now, since my folders are in Cyrilyc letters. I get error at: <#list companyhome.childByNamePath["Cyrilyc folder name"].children as child> If I change the folder with English name, it works. I have no idea what to do. – The Macedon Oct 16 '14 at 12:34