Tuesday, March 13, 2012

Custom Document Library Action Evaluator


Custom Evaluator for Document Library Action

Sometimes we need to show certain custom action on specified type of content only. Not all content show that custom action, because we need to evaluate to certain actions only.

This example explain simple custom evaluator in alfresco 4 share document library in which I want to display my custom action only on clm:Draft kind of type content only.

To make this enable we need to modify following files:
  1. share-config-custom.xml
  2. custom-slingshot-application-context.xml

  1. share-config-custom.xml
This file contains custom action and actionGroup entry.
Action entry contains information about the new custom link we are adding to action like below:

<actions>
<action id="folder-assign-workflow" type="pagelink" icon="folder-manage-permissions" label="Start Draft Workflow">
<param name="page">documentlibrary?nodeRef={node.nodeRef}</param>
<evaluator>evaluator.doclib.action.draftTypeFolder</evaluator>
</action>
</actions>

ActionGroup is the group in which we are adding our custom action entry
<actionGroups>
<actionGroup id="folder-browse">
<action index="161" id="folder-assign-workflow" />
</actionGroup>
</actionGroups>

So total entry looks like below :

<config evaluator="string-compare" condition="DocLibActions"> 
<actions> 
<action id="folder-assign-workflow" type="pagelink" icon="folder-manage-permissions" label="Start Draft Workflow"> 
<param name="page">documentlibrary?nodeRef={node.nodeRef}</param> 
<evaluator>evaluator.doclib.action.draftTypeFolder</evaluator> 
</action> 
</actions> 
<actionGroups> 
<actionGroup id="folder-browse"> 
<action index="161" id="folder-assign-workflow" /> 
</actionGroup> 
</actionGroups> 
</config>
  1. custom-slingshot-application-context.xml
This file contains evaluator entry.

<bean id="evaluator.doclib.action.draftTypeFolder" parent="evaluator.doclib.action.nodeType">
<property name="types">
<list>
<value>clm:Draft</value>
</list>
</property>
</bean>

11 comments:

  1. Hi, thanks for post,

    if I want to create a custom action with a javascript controller where I place my javascript file? I use Alfresco 4.

    Regards and thanks.

    ReplyDelete
    Replies
    1. Hi sil,
      you can find inside action.js (client side documentlibrary)
      you can add your custom method there.

      Delete
  2. Hi Ghanshym, thanks for reply,

    I do not mean the client side I have to create an action on a folder that does operations in javascript, where should I put the files?

    Thanks

    ReplyDelete
    Replies
    1. Can you please elaborate more what exactly you want to achieve, because to perform an action here client side js or custom script call to repository is necessary.

      In javascript operation you place your method inside action.js as I mention earlier.

      Delete
    2. yes,

      I need to create a script in javascript that works on a folder and allows you to create a DataList type contact.

      The datalist must have the same folder name and the fields are dynamically filled with the properties of the document placed in the folder.

      Thanks a lot.

      Delete
  3. Alfresco is not only a simple document management system, it offers rich set of Web 2.0 collaboration features.

    alfresco workflow

    ReplyDelete
  4. How can I make 'Create Content' and 'Create Group' available(enable) for custom roles that I've made ?
    Also how can I disable download button for all roles ?

    ReplyDelete
  5. is there anyway to display only draft object in document library or repository?I want to filter object.I want to put that filter on toolbar

    ReplyDelete
    Replies
    1. Hi Krutik, can you elaborate your requirements? You can display your action based on your evaluator condition or based on your custom evaluator condition.

      Delete
  6. I know i can display my custom action but i would like to do following:

    one button on toolbar on click of that,spaces(folders) which are displayed will be filtered based on some property.

    consider an example ,suppose all object has field named status .I want to display only those objects whose status is draft.This should happen when i click on button that is on toolbar.

    ReplyDelete
    Replies
    1. Hi Krutik,

      In your case I dont think you need evaluator. But you should check on your button click and fire a query to repository to fetch your custom type object (e.g. draft kind of content) , simply fire query with your type = draft. to display those result.

      Delete