cancel
Showing results for 
Search instead for 
Did you mean: 

Custom email action

nancyaggarwal
Champ in-the-making
Champ in-the-making
Hi All

I have to make a custom email action in more menu in document library section. I succeeded in showing the action in drop down menu by following the blog
http://ecmstuff.blogspot.in/2012/04/adding-document-library-actions-in.html

but when click on it, the form is not showing the labels in it.


How can i get the form with the labels (To, subject and body).



Thanks
Nancy


37 REPLIES 37

Hi Emmanuel

Its working now… Thanks…thanks a lot for your support.


Nancy

ecarbenay
Star Contributor
Star Contributor
Hi Nancy,

happy to here that it's working now !
Please for everybody can you explain what you've done to make it work, and what were the difficulties you met ?

hi Emmanuel

I defined the sendAsEmail bean configuration in action-services-context.xml file and defined form in share-form-config.xml


One more thing i want to ask how we come know what file we have to put where in alfresco?


Nancy

ecarbenay
Star Contributor
Star Contributor
Hi Nancy,

your question is not so easy to answer, because it depends the way you want to configure your Alfresco instance.

To start, if you want only to add some configuration files, you can follow the path described in the documentation : http://docs.alfresco.com/4.2/topic/com.alfresco.enterprise.doc/reuse/conv-syspaths.html
Place your files on the required path.

Then if you want to package an extension in an AMP or in a JAR, you can use Eclipse and Ant to build your extension, and deploy it. An eclipse project will let you use a predefined folder structure to assure you that your files will be placed at the right place.
You will find more documentation in this presentation : http://fr.slideshare.net/alfresco/share-customization-best-practices
This slideshare presentation talks about share extras (http://code.google.com/p/share-extras/), which is a very good place to find a sample project (http://code.google.com/p/share-extras/wiki/DevelopmentEnvironment) and examples about how to build extensions.
Another article I recommend you is following, still from Martin Bergljung : http://www.ixxus.com/blog/2011/07/setting-build-project-alfresco-explorer-share-and-wqs-extensions

Does it answer to your question ?

Hi Emmanuel

Thanks for your reply. Yes these links are  really very useful..thanks for them.

One more thing: I am also thinking to make a custom backup action that is available online but after placing all the files still i am not able to do anything. when i click on it, it doesn't call the javascript action.


Thanks
Nancy

You can write and execute scripts from the Data Dictionary.
1.Writing and storing scripts in the Data Dictionary,for example create a file called backup.js and store it in the Company Home > Data Dictionary > Scripts space.
2.Creating a new rule  for a folder,under perform action, select Execute script and in the drop-down box that appears, select backup.js, which is the JavaScript file we created earlier,also you can execute an action manually.

ecarbenay
Star Contributor
Star Contributor
Hi Nancy,

you're talking about a new action you're trying to implement. I think you'd better to create a new topic in the forum for that.
Please give more details about the action you want to implement, and the starting point you followed in order to be able to help you.

Hi Emmanuel

I want to make a backup action in the document library i.e when a user click on this action the documents moves to the folder which is not accessible to the user ,only admin has the access. For this action i define the action in share-documentlibrary-config.xml


<action id="document-archive" type="javascript"  label="actions.document.archive">
                <param name="function">onActionBackup</param>
               
            <permissions>
            <permission allow="true">Delete</permission>
            </permissions>
                <param name="successMessage">message.archive.success</param>
                <param name="failureMessage">message.archive.failure</param>
                <evaluator negate="true">evaluator.doclib.action.isLocked</evaluator>
            </action>



and created ArchiveActionExecuter


package org.alfresco.repo.action.executer;

import java.util.List;

import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class ArchiveActionExecuter extends ActionExecuterAbstractBase{
   private static Log logger = LogFactory.getLog(ArchiveActionExecuter.class);
   
    public static final String NAME = "archive";
       public static final String PARAM_DESTINATION_FOLDER = "archive_store";
   
      
       private FileFolderService fileFolderService;
    
    
        public void setFileFolderService(FileFolderService fileFolderService)
       {
           this.fileFolderService = fileFolderService;
       }
      
      @Override
       public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef)
      {
         logger.debug("######################1");
          NodeRef destinationParent = (NodeRef)ruleAction.getParameterValue(PARAM_DESTINATION_FOLDER);
              try
              {
                 logger.debug("######################2");
                  fileFolderService.move(actionedUponNodeRef, destinationParent, null);
                  logger.debug("######################3");
              }
              catch (FileNotFoundException e)
              {
                 logger.debug("######################4");
                  // Do nothing
              }
}


       @Override
       protected void addParameterDefinitions(List<ParameterDefinition> paramList)
       {
           paramList.add(new ParameterDefinitionImpl(PARAM_DESTINATION_FOLDER, DataTypeDefinition.NODE_REF, true, getParamDisplayLabel(PARAM_DESTINATION_FOLDER)));
       }
      }



and javascript code in actions.js


(function()
      {
       /**
      * Backup single document.
      *
      * @method onActionBackup
      * @param file {object} Object literal representing one or more file(s) or folder(s) to be actioned
      */
    YAHOO.Bubbling.fire("registerAction",

             {

                 actionName: "onActionBackup",

                 onActionBackup: function dlA_onActionBackup(record)

       {
   alert("TEST");
         
              var displayName = record.displayName;

              var nodeRef = record.nodeRef;

      this.modules.actions.genericAction(
      {
       success:
       {
      event:
      {
       name: "metadataRefresh"
      },
      message: this.msg("message.archive.success", record.displayName)
       },
       failure:
       {
      message: this.msg("message.archive.failure",record.displayName)
       },
      
       webscript:
       {
      name:"/slingshot/doclib/action/archive/site/{site}/{container}",
      method: Alfresco.util.Ajax.POST
       },
       params:
       {
      site: this.options.siteId,
      container: this.options.containerId
       },
       config:
       {
      requestContentType: Alfresco.util.Ajax.JSON,
      dataObj:
      {
       nodeRefs: [record.nodeRef]
      }
       }
      });
       }
       });
      
      })();





When i click on the action it doesn't do anything.


I have also created a new topic in the forum for the same
https://forums.alfresco.com/forum/developer-discussions/alfresco-share-development/custom-backup-act...

Thanks
Nancy