Custom action in share documentlibrary

There are multiple types of action available in alfresco share which you can add in document library.Few examples are already available in internet for adding custom action in alfresco share.The most common exmaple is adding an action called send-as-email in document library.That exmaple is added in documentation of alfresco share as well.Take a look on below link for same.

http://docs.alfresco.com/5.0/tasks/dev-extensions-share-tutorials-add-action-doclib.html

There are multiple business cases in which you need to implement custom action in alfresco.This blog will give you description about what kind of things you can achieve in custom action of alfresco share.

Below is screenshot of document details page on which custom actions are highlighted.




There are few components which can be customized or used in alfresco for implementation of custom action in alfresco share.Those are as below.

Evaluator
Using evaluator we can control the visibility/access of action for users.There are multiple parameters by which we can control the visibility. Evaluation of node can be done on aspects, properties state of node or the type of node.

Type of action
There are multiple type of action you can create in share.All of them are as below.

javascript
With the use of this type of action you can call java script function.Lets take an example.Take a look on below code.



   onActionFormDialog
   action
   script
   create
   {node.nodeRef}
   message.execute-script.success
   message.execute-script.failure



If you take look on each param which is passed in function, than you will realize that all of those params are related to form.The parameter named function is used for identification for which function function is called. Rest of all params are used inside that function.There are some predifined javascript function which you can use.Please take a look on actions.js file in alfresco share for all function.If you are using this function, you have to create action-executor with the same id of action.

page

Redirection to internal application(Withinn pages of alfresco share)

link
Redirection to external web application, for example redirection to http://www.google.com
Any of above action can be visible on any/all of the below section.

  1. Folder Details
  2. Folder Browse
  3. Document Details
  4. Document Browse
  5. Folder Link Browse
  6. Folder Link Details
  7. Document Link Browse
  8. Document Link Details


Below is sample code for adding action on desired location.
 

 
  
   onActionFormDialog
        
   action
        
   script
        
   create
        
   {node.nodeRef}
        
   message.execute-script.success
        
   message.execute-script.failure

  
 
 
  
   
  
  
   
  
  
   
  
  
   
  
 


In above index attribute is index of action in the list of action.

Share this: