How can I execute a Java script before creating new content

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

How can I execute a Java script before creating new content

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">
                        <content id= ....


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>



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

Thank you in advance.

1 Reply
Established Member II

Re: How can I execute a Java script before creating new content

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">
<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