cancel
Showing results for 
Search instead for 
Did you mean: 

Start workflow via JavaScript with the help of rules

fbehfar
Champ on-the-rise
Champ on-the-rise
Hi,
I want to create a rule, with the "execute a script" actions. I want to start the advanced workflow with the help of the rules.

Actually I want to automaticly start the workflow by adding a new content.

for example:
a user adds a content
the (whitepaper) workflow starts in backgroound and send a task for a specific users,
these users recieve a task on their pool tasks list.

Is it possible to start a workflow by defining a rule, at the time of adding a new content????
I guess one solution is to use the javascript in the rule definition, but how should the script look like?

Thank you,
FSB
34 REPLIES 34

hi
where did you define javascript file and how you integrate it .

kashyap_kk
Champ in-the-making
Champ in-the-making
hi,
i have kept my workflow process defination file in alfresco/classes/workflow folder and my java script in datadictionary/scripts folder also i have defined my process defination in bootstrap-context.xml as well but still when i approve a document it does not get moved to appropriate folder


and thanks for reply…..

kashyap_kk
Champ in-the-making
Champ in-the-making
hi,
   i have my approve and rejected folders in company home am i giving the right paths in javascript above if any idea please help….

kossinus
Champ in-the-making
Champ in-the-making
hi Kashyap,
are you solved your problem.?

ruchin78
Champ in-the-making
Champ in-the-making
Hi Everyone,

I am using the below code:
—–
function startWorkflow(assigneeGroup)
{
    var workflow = actions.create("start-workflow");
    workflow.parameters.workflowName = "activiti$activitiReviewPooled";
    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(group);

      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();
—————–
It is all working fine, but I want something more in it.
For example a user added a file called DCN10007.pdf and other supporting files of DCN10007.pdf user will tag the filename under each supporting file say for example.
XYZ.docx
ABC.XLSX
As both the above files are supporting documents of DCN10007.pdf, then user will add tag as "DCN10007" in both of the documents.

Now, I want that when a file with the name DCN is uploaded I get workflow created for all the 3 documents.
I appreciate, if anyone can tell me how to achieve this.

Regards
Ruchin Sharma