cancel
Showing results for 
Search instead for 
Did you mean: 

JavaScript function inside workflow action

chicco0386
Champ on-the-rise
Champ on-the-rise
Hi all,
I'm looking how to define and insert javascript function inside a workflow.
For example

<node name="Genera template documenti">
        <action class="it.mytria.tria.wf.action.GeneraTemplate"></action>
        <event type="node-enter">
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                <runas>admin</runas>
                <script>
                    ———–Function/s———-
                </script>
            </action>
        </event>
        <transition to="End"></transition>
    </node>


It's possible?
How can I do this?

I hope that this solution it's possible, beacuse it make the code more simply and reusable.

I attend yours responses?
THANK YOU
2 REPLIES 2

sebp
Champ in-the-making
Champ in-the-making
I'm not sure if you can use functions in the <script> element but you can import other javascript files and use the functions defined in there:


<node name="Genera template documenti">
        <action class="it.mytria.tria.wf.action.GeneraTemplate"></action>
        <event type="node-enter">
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                <runas>admin</runas>
                <script>
                    &lt;import resource="classpath:alfresco/module/myworkflowmodule/workflows/workflow.js"&gt;
                    — javascript —
                </script>
            </action>
        </event>
        <transition to="End"></transition>
    </node>

See also:
http://wiki.alfresco.com/wiki/JavaScript_API_Cookbook#Include_two_other_javascripts.2C_one_from_the_...

chicco0386
Champ on-the-rise
Champ on-the-rise
Thank you for the fast reply, I try this solution, but when I import the js file, all the code inside the imported js will automatically excetue?
And how I can use the function of the imported js?

THANK YOU