AnsweredAssumed Answered

Custom action using server side javascript

Question asked by robert.begin on Dec 3, 2013
Latest reply on Jun 20, 2017 by sakshik
I would like to add a new action on Share's document-browse page (Alfresco 4.1) which executes a server side-javascript residing in repo at companyhome\Data Dictionary\scripts\mypublish.js

The javascript transforms the doc to PDF and moves it to a static folder.  (No client-side javascript is required)
The javascript works fine when tied to a folder rule, but I want the users to choose my "Publish to PDF" icon when a particular document needs to be published (not all docs in particular folder need to be published)

I've added this to share-config-custom.xml :

<!– Custom DocLibActions config section –>
  <config evaluator="string-compare" condition="DocLibActions">
      <action id="mypublish" icon="publish" type="javascript" label="actions.mycompany.mypublish">
        <param name="function">onActionSimpleRepoAction</param>
        <param name="action">mypublish</param>
       Action Group definitions
      <actionGroup id="document-browse">
        <action index="400" id="mypublish" />

So the icon appears on the document-browse Share page, but clicking the icon does not launch the s-s javascript.

BUT how do I configure this through Spring ???

Noted from JPotts:

A quick side-note before moving on to the front-end: The action executer examples shown in Part 1
were both implemented in Java. However, action executers can also be implemented using server-side
JavaScript. The steps are the same: write the logic, then configure it through Spring.

I know I can accomplish this with the "document-execute-script" action, but the user has the extra step of selecting the proper javascript.