AnsweredAssumed Answered

Add an archive action

Question asked by morganp1 on May 13, 2013
Latest reply on May 21, 2013 by morganp1

I am currently working on Alfresco 4.2 and I have to add an 'Archive' action (simply a move to a folder that the user can't choose) to the list 'Document Actions' just below the other as 'Download', 'Copy to …', 'Move to …', etc.

I started by adding a button in a 'share/WEB-INF/classes/alfresco/web-extension/share-config-custom.xml' (actually two buttons, the second is to test the java code):

<config evaluator="string-compare" condition="DocLibActions">
            <action id="document-archive" type="javascript" label="actions.<myCompany>.archive">
                <param name="function">onActionArchive</param>
                <param name="successMessage">message.archive.success</param>
                <param name="failureMessage">message.archive.failure</param>
                <evaluator negate="true">evaluator.doclib.action.isLocked</evaluator>
            <action id="document-execute-script" type="javascript" label=""></action>
            <actionGroup id="document-browse">
                <action index="264" id="document-archive"/>
                <action index="266" id="document-execute-script"/>

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

            <!– <css src="my-custom-action.css" /> –>
            <js src="components/documentlibrary/archive.js"/>


From there, I have a file in the same place 'custom-slingshot-application-context.xml' to define a Bean whose value is 'alfresco.messages.custom'. So then I change the text displayed on the buttons to a file 'messages/'.

I also have a file 'share/components/DocumentLibrary/archive.js' which automatically generate a -min.js and an image 'share/components/documentlibrary/actions/document-archive-16.png' for my button. Until then, everything works exactly as I expected.

So now we have to add an action behind the button and that's where the trouble begins. Alfresco side this time, I created a class 'ArchiveActionExecuter' that extends 'ActionExecuterAbstractBase' and does what I want. As for I have a Bean that allows me to reference this class:

<bean id="archive" class="org.alfresco.module.<myCompanyAmp>.ArchiveActionExecuter" parent="action-executer">
        <property name="serviceRegistry">
            <ref bean="ServiceRegistry"/>
        <property name="repository">
            <ref bean="repositoryHelper"/>

What should I do to call my java class when I press my 'Archive' button? What should be put in the file 'archive.js' I mentioned above?

Currently, I'm sure my java class is good because if I add a file archive-action.js, for example, in the repository under 'Company Home/Data Dictionary/Scripts' with:

var archiveAction = actions.create("archive");

If I click on my second button and I choose the script I just added (archive-action.js), then my java class is called and the action is done the way I want.

Now, if I click on the 'Archive' button, nothing happens.

Currently, in the file 'share/components/DocumentLibrary/archive.js' I have the following code:

(function() {"registerAction",
        actionName: "onActionArchive",
        fn: function <myCompany>_onActionArchive(file) {
           var archiveAction = actions.create("archive");

I think the problem come from that file but I'm a little confused and do not really see what's missing for the action to be launched when a user click on the button, so if someone could help me it would be very nice!

Thank you for reading and for your help

Edit: I would also say that my action 'archive' appears and could be used as a 'Content rule' (can be added to a file so that as soon as someone uploads a document, this action is called for example).