cancel
Showing results for 
Search instead for 
Did you mean: 

Using ajax in a rule

jsolan
Champ in-the-making
Champ in-the-making
I'm trying to setup a rule to add information to a file and copy it to a proper location in alfresco 3.4.d.
Basically users are going to be scanning a document to the share and will have limited interaction.  Based on the filename they give I'm going to look up other information from a database.
What I would prefer to do is make an ajax call from a rule on the folder to a php script that returns the necessary information.

I'm familiar with dojo and the dojo.io.bind function as shown on the wiki here http://wiki.alfresco.com/wiki/AJAX_Support
But it's not clear to me if/how these can be used in a script when creating a rule.

I've tried making a dojo build with the needed files, uploaded it to the scripts directory, and attempted :
<import resource="/Company Home/Data Dictionary/Scripts/dojo.js">
which i found in the wiki here http://wiki.alfresco.com/wiki/JavaScript_API_Cookbook
I get an syntax error when trying to execute my script with that import line in there
15:28:32,301 ERROR [org.springframework.extensions.webscripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: 04099633 Failed to execute script 'workspace://SpacesStore/a5ea6262-1062-4892-b200-922a9b6659df': syntax error (workspace://SpacesStore/a5ea6262-1062-4892-b200-922a9b6659df#12)
org.alfresco.scripts.ScriptException: 04099633 Failed to execute script 'workspace://SpacesStore/a5ea6262-1062-4892-b200-922a9b6659df': syntax error (workspace://SpacesStore/a5ea6262-1062-4892-b200-922a9b6659df#12)
.

Any help would be greatly appreciated.
1 REPLY 1

jsolan
Champ in-the-making
Champ in-the-making
So I realized that the import statement was not the very first thing in my script which is why I was getting a syntax error.  After that I started getting a java is undefined message.  This is using the dojo build profile for rhino.  I'm really flying blind with this though as I've never used rhino before.

13:02:56,978 ERROR [org.springframework.extensions.webscripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: 04130973 Failed to execute script 'workspace://SpacesStore/a5ea6262-1062-4892-b200-922a9b6659df': 04130972 ReferenceError: "java" is not defined. (workspace://SpacesStore/a5ea6262-1062-4892-b200-922a9b6659df#14)
org.alfresco.scripts.ScriptException: 04130973 Failed to execute script 'workspace://SpacesStore/a5ea6262-1062-4892-b200-922a9b6659df': 04130972 ReferenceError: "java" is not defined. (workspace://SpacesStore/a5ea6262-1062-4892-b200-922a9b6659df#14)

Is it just not possible to use ajax in a rule?  Are there any options for doing realtime validation for files?
One of the things we liked about alfresco is that we thought we could cleanse data without having to write our own interfaces.  Now it's looking more like that isn't the case.
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.