I want to create a workflow using JavaScript with multiple files attached in the workflow for review.
Below code works only for any single file added to the alfresco.
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; workflow.document 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."); } }
1) How you're triggering the rule? 2) If you're triggering the rule on a file, obviously the current file node will be picked and it is triggering the workflow?
Anyway, I will take a look, how we can start the workflow with multiple attachments via Javascript console.
Thanks a lot for your response, I am eagerly waiting for the reply. Also, as far as triggering is concern, I am triggering on the current file node, because I really don't know the way to trigger it on multiple files. I am very new to Alfresco as well as Javascript but it will be really appreciable, if you can help me in this regard.