Skip navigation
All Places > Alfresco Content Services (ECM) > Blog > Authors sakshik

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:

Alfresco SDK Setup on Eclipse

  1.      Install Maven:
  •    Add the path of bin folder of the created directory apache-maven-3.5.0 to the PATH environment variable

Confirm with mvn –v after entering bin directory.


  1.      Create Maven project:
  •    Open eclipse

   Make sure your internet connection doesn't have a firewall enabled 

  •  Go to Windows – Open Perspective – Java
  •  File – New –Project – Maven Project – Leave everything as default - Click Next – Click on Configure button – Add Remote catalog –

Catalog File:

          Description: Alfresco Public

  •     Click OK
  •     On the ‘New Maven Project’ dialog, select All catalog in the drop down
  • Type org.alfresco.maven in the filter: select allinone – Click Next

Group Id:

Artifact Id: ws4js-repo

  •    Click on Finish
  1.         If an error comes saying plugin execution not covered by life cycle configuration.

Right click on error – Quick fix – select permanently mark goal run in pom.xml as ignored in Eclipse build 

  1. 4. Right click on project – Select Maven- Update project
  2.      Create custom Run Configuration for Maven project:
  • On the Eclipse toolbar select 'Run', and then 'Run Configurations’ – This will open the 'Run Configurations' dialog box.
  • Select the Maven Build

"Maven Integration Test REPO" and edit the Base directory to point to your project. Make sure it

Matches the following:

Base directory: ${workspace_loc:/ws4js-repo}

In Goal: clean install –DskipTests=true alfresco:run


Note: If an error comes saying: no compiler is provided in this environment perhaps you are running on a jre instead of jdk

Go to Windows – Preferences – Java – Installed JREs

Change the path from jre to jdk click OK

Then Run the same way.

It will take some time


  1.     Check browser : localhost:8080/share


Login: admin

Password: admin

Filter Blog

By date: By tag: