cancel
Showing results for 
Search instead for 
Did you mean: 

how to execute script with direct URL?

targa2000
Champ in-the-making
Champ in-the-making
How do we execute a script with direct URL?

In Alfresco wiki :

http://wiki.alfresco.com/wiki/3.0_JavaScript_API#Executing_Scripts_in_the_Alfresco_Explorer_Web_Clie...

The second way is to use direct URL addressing for a REST-style of execution. The Alfresco web client features a generic 'command' servlet that allows the execution of scripts directly via URLs. This feature allows direct access to scripts and the result of the script is returned as the HTML response stream. See the Command Servlet documentation for more information on this servlet.

In the script command processor section:

Responsible for processing an Alfresco JavaScript through the 'execute' command. The NodeRef supplied as the first 3 arguments of the node specify the script to execute. Optionally an additional NodeRef can be specified to provide a document node context to the script (in addition the parent folder of the document node will then be used as the space context to the script). Returns the result of the script (if any) converted to a string as the HTML response. See the JavaScript API page for more information on the Alfresco JavaScript API.

Examples:

/alfresco/command/script/execute/workspace/SpacesStore/d8470f03-b80a-11da-97b9-8d453af5a554
/alfresco/command/script/execute/workspace/SpacesStore/d8470f03-b80a-11da-97b9-8d453af5a554/workspace/SpacesStore/12345678-9012-11da-97b9-8d453af5a554
Any additional URL parameter arguments can be passed to the servlet, they will be collected and supplied to the scripting data-model into an associative JavaScript array object called args. The args object is accessable from the root of the script scope and contains all the URL name/value pairs supplied to the servlet.

Where do we get the coreect NodeRef to execute for a script?
2 REPLIES 2

openpj
Elite Collaborator
Elite Collaborator
You have to upload the script in the Data Dictionary -> Scripts space.
Then you need to click on "View Details" of this script in the repository and copy the link of Alfresco Node Reference.
This is the Alfresco Node Reference that you need to use to invoke this script using the servlet.

Hope this helps.

jpfi
Champ in-the-making
Champ in-the-making
Hi, you can also use pathes here:
wiki:
The reference to the script or the context node can now be specified as 'scriptPath' and 'contextPath' URL arguments rather than as NodeRef elements. For example:

/alfresco/command/script/execute?scriptPath=/Company%20Home/Data%20Dictionary/Scripts/append%20copyright.js&contextPath=/Company%20Home/file.txt

Paths are specified in a similar way to a WebDav path - they are 'cm:name' based URL encoded strings.

Note that the entire URL must be URL encoded appropriately.
Cheers, Jan
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.