12-12-2017 01:54 PM
I need to call an external class when an update is made to the document in the folder. The rule will execute a javascript.
I would like to know or read about how to make this class call by javascript.
If it is possible?
Can someone help me?
12-12-2017 02:41 PM
Folder rules can invoke Java classes that are instances of ActionExecuterAbstractBase. That means you can write your own Java class and make a call to any other class on the classpath.
Folder rules can also execute JavaScript. That's because there is a Java class that extends ActionExecuterAbstractBase that knows how to run JavaScript.
So, your first option is to write a Java class, extend ActionExecuterBase, and call your class from there.
But you said you want to call JavaScript and your JavaScript is going to call a class. That's kind of "the long way around" but it's perfectly fine. In that case, you'll need to write a Java class that is a scope processor extension. Basically it just exposes your Java class to JavaScript. That class can call the other Java class that is on the classpath, and because it is a scope processor extension, it will be exposed as a root variable in Alfresco's server-side JavaScript.
All that's left to do at that point is set up your folder rule, use the "Execute Script" action, and point to your server-side JavaScript that makes the call to your new root variable.
12-13-2017 06:43 AM
Many thanks Jeff.
Would you have any examples or reference books for me to take as a basis?
For I am extremely new to this scenario.
Thanks
12-13-2017 02:37 PM
My actions tutorial shows how to write an action, but I do not show how to do the processor extension.
However, the ACL Templates add-on that I maintain on behalf of one of my clients has an example of this. The AclTemplateServiceScopedObject class exposes the Java-based ACL Template Service to JavaScript.
12-14-2017 07:32 AM
Thanks Jeff.
Very helpful and helped a lot.
BS
Explore our Alfresco products with the links below. Use labels to filter content by product module.