0
votes

In Alfresco-Share 4.2 you have the option to define rules on a folder. One of the pre-defined options is the script execution. I would like to execute a script witch launch the execution of a custom-workflow but I haven’t seen any example of this and where you have to put this script.

Moreover, in the out-of-the-box configuration, when you choose the option of script execution, you have the possibility (only) to execute one script called “Start workflow of review and approve in group”, but if I choose this option and create the rule in the folder, this rule doesn’t make anything when the event in the folder is produced.

***** Adding info to the First and Second answer ******************* I'm using Alfresco Enterprise Edition in a Windows 7 environment, and I don´t have any folder called "Data Dictionary" and in my installation doesn't exist any file called "start-pooled-review-workflow.js". I'll install Community Edition in other Pc to find this folder if the problema is this.

Could you write the full path where I have to put the script?. The other alternatives that you mention are difficult for me.

And one thing more, I am trying to do this workflow with activiti and I don't know where I should change and where is the alfresco-global.propierties. I have been locking for a file called alfresco-global.propierties but it doesn't exist in my installation.


1

1 Answers

1
votes

The script start-pooled-review-workflow.js shipping with Alfresco is actually a nice example how to kick off a workflow. You should find it at "Repository> Data Dictionary> Scripts". Here it is:

function startWorkflow(assigneeGroup)
{
    var workflow = actions.create("start-workflow");
    workflow.parameters.workflowName = "jbpm$wf:reviewpooled";
    workflow.parameters["bpm:workflowDescription"] = "Please review " + document.name;
    workflow.parameters["bpm:groupAssignee"] = assigneeGroup;
    var futureDate = new Date();
    futureDate.setDate(futureDate.getDate() + 7);
    workflow.parameters["bpm:workflowDueDate"] = futureDate; 
    return workflow.execute(document);
}

function main()
{
   var name = document.name;
   var siteName = document.siteShortName;

   if (siteName == null)
   {
      if (logger.isLoggingEnabled())
         logger.log("Did not start workflow as the document named " + name + " is not located within a site.");

      return;
   }

   var reviewGroup = "GROUP_site_" + siteName;

   // make sure the group exists
   var group = people.getGroup(reviewGroup);
   if (group != null)
   {
      if (logger.isLoggingEnabled())
         logger.log("Starting pooled review and approve workflow for document named " + name + " assigned to group " + reviewGroup);

      startWorkflow(reviewGroup);

      if (logger.isLoggingEnabled())
         logger.log("Started pooled review and approve workflow for document named " + name + " assigned to group " + reviewGroup);
   }
   else if (logger.isLoggingEnabled())
   {
      logger.log("Did not start workflow as the group " + reviewGroup + " could not be found.");
   }
}

main();

I would guess it is failing for you because the jbpm engine is disabled by default in recent versions of Alfresco. Setting

system.workflow.engine.jbpm.enabled=true

in alfresco-global.properties should do the trick.

So just drop your script in the Scripts folder of Data Dictionary. (An alternative would be creating a spring managed bean deriving from script or an Action coded in Java).

If "Start workflow of review and approve in group" is the only option you get for script execution, there is most likely something wrong with your installation.