Help with creating web-scripts

Showing results for 
Search instead for 
Did you mean: 
Active Member

Help with creating web-scripts

Hi, I'm new to Alfresco and according to some needs, I need to work on some web-scripts to automate a few things. I got into it followig some examples from JavaScript API Cookbook | Alfresco Community but I can't seem to get them to work.

I made a simple script with Javascript to create a folder, making use of this function: createFolder | Alfresco Documentation.

I copied the .js (with that function call) and .desc files into /Data Directory/Web Scripts/org/alfresco/sample, but when I go to alfresco:8080/alfresco/services/createFolder I see a message saying:

ReferenceError: "userhome" is not defined.

Looks like I can't access any Root Object and I honestly don't know what's going wrong here.

As I said the Javascript file only contains a call to the createFolder() function (actually copied the line of code from the docs) and the desc.xml file contains:

  <shortname>Ejemplo para crear directorio</shortname>
  <description>se crea directorio</description>

Am I missing something? Any help would be much appreciated.

1 Reply
Senior Member

Re: Help with creating web-scripts


Maybe this link could be useful:

java - How can I be able to create a folder node on companyhome in Alfresco? - Stack Overflow 

After upload the files to "Repository" you have to check if the new webscript is available. 

Visit the url: http://localhost:8383/alfresco/service/index  (it depends of your alfresco server) and click on "Refresh Web Scripts"

You can test the example: http://localhost:8383/alfresco/service/createfolder?folderName=test123 (something like that changing server and port) and you'll obtain a response similar to:

Successfully created a folder with the following metadata:
Name: test123
ID: d241a1ff-ab61-4002-a1fb-367e4f626309
Noderef: workspace://SpacesStore/d241a1ff-ab61-4002-a1fb-367e4f626309

This folder are created under "Repository" but you can try to find exactly what you need, I mean create a folder under userHome.