cancel
Showing results for 
Search instead for 
Did you mean: 

How can I execute a Java script before creating new content

hackerkok
Champ on-the-rise
Champ on-the-rise

I want to execute a Java script on content creation. The script should fetch a document from a url, given some parameters on a popup (same as the folder creation popup) and then upload it to alfresco.

I have followed the instructions here Adding a menu item to the "Create..." menu in DocLib | Alfresco Documentation but I can not find a way to initiate the Java code.

My content is type javascript:

<config evaluator="string-compare" condition="DocumentLibrary">
                    <create-content>
                        <content id= ....
                                 type="javascript">

.....

The function I used is onActionFormDialog, same as the document actions is done, but this doesn't seem to work.

 ....

                            <param name="function">onActionFormDialog</param>
                            <param name="itemKind">action</param>
                            <param name="itemId">...</param>  Repository action id = Spring Bean id
                            <param name="mode">create</param>
                            <param name="destination">{node.nodeRef}</param>
                            <param name="successMessage">...</param>
                            <param name="failureMessage">....</param>

 </content>
 </create-content>

.....

I guess that the onActionFormDialog function can not be used here, but I can not find an alternative.

Thank you in advance.

1 REPLY 1

roberto_gamiz
Star Contributor
Star Contributor

Hello Pitsinis,

Can't you create a custom action on folder level instead a new item in the create menu? I think it would be a more accurated solution.

Anyway you could try to overwrite the url for content creation in the definition of the creation form of your type..

<config evaluator="model-type" condition="wscm:sociedad">
<forms>
<form submission-url="<your web script url>">

You can use property submission-url to modify the web script to handle the creation of the content and implement in this web script all your custom logic.

Maybe you want to take a look of

http://docs.alfresco.com/community/references/dev-extension-points-form-processors.html

Regards