Add Custom Action Button Using Javascript

Showing results for 
Search instead for 
Did you mean: 

Add Custom Action Button Using Javascript

Established Member
6 2 3,961

Steps to add a custom button/link in Document Actions and Folder Actions on Document and Folder Level:

Step 1: Create a directory scripts in ...\tomcat\shared\classes\alfresco\extension\

Step 2 :

cd into ...\tomcat\shared\classes\alfresco\extension\scripts

Create a file publishDoc.js


document.copy(DestNode) - [write script according to your requirement]


Step 3:

Registering action

Create a context file custom-action-services-context.xml in \tomcat\shared\classes\alfresco\extension\ with the following code :


<?xml version='1.0' encoding='UTF-8'?>
   <bean id="publish-doc-action" parent="script">
      <property name="scriptLocation">
      <bean class="org.alfresco.repo.jscript.ClasspathScriptLocation">

Step 4:

Calling action

Add the following code to tomcat\shared\classes\alfresco\web-extension\share-config-custom.xml:

<config evaluator="string-compare" condition="DocLibActions">

Action definitions
<!– Publish Document –>
   <action id="publish-doc" icon="ic-publish" type="javascript" label="Publish">
      <param name="function">onActionSimpleRepoAction</param>
      <param name="action">publish-doc-action</param>
      <param name="successMessage">Successfully Published</param>
      <param name="failureMessage">failed</param>


<!-- For action button to show up at document level -->
   <actionGroup id="document-browse">
      <action index="460" id="publish-doc"/>
   <actionGroup id="document-details">
      <action index="400" id="publish-doc"/>

<!-- For action button to show up at Folder level -->

   <actionGroup id="folder-browse">
      <action index="460" id="publish-doc"/>
   <actionGroup id="folder-details">   
      <action index="400" id="publish-doc"/>


Step 5: Add icon image named ic-publish-16.png in tomcat\webapps\share\components\documentlibrary\actions\

Restart Alfresco server

You will be able to see a button in document Action and in Folder Action: