0

I want to add a workflow on all files in a folder automatically thanks to a content rule. I've seen that one workflow already exists (review group) but I want to add one that permits only to Site manager to valid the document (manager review). I've add a javascript script, this is my code that don't work :

var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:parallelgroupreview";
workflow.parameters.requiredApprovePercent = 20;
workflow.parameters["bpm:workflowDescription"] = "Please review and approve: " + document.name;
workflow.parameters["bpm:assignee"] = site.listMembers(null, "manager", 0, true);
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.execute(document); 

Please, can you help me because I'm a bit confused.

Thanks !

1 Answer 1

1

You'll have to use a little tweak to get the SiteManager-Group for a document. The following snippet will start a parallel-group-review workflow. I've used the workflow that is based on activiti as I would recommed to use activiti instead of jbpm:

var ctx = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
var javaSiteService = ctx.getBean("siteService");
var site = javaSiteService.getSite(document.nodeRef);
var siteManagerGroup = javaSiteService.getSiteRoleGroup(site.getShortName(), "SiteManager", true);
var groupAssignee = people.getGroup(siteManagerGroup)

var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "activiti$activitiParallelGroupReview";
workflow.parameters.requiredApprovePercent = 20;
workflow.parameters["bpm:workflowDescription"] = "Please review and approve: " + document.name;
workflow.parameters["bpm:groupAssignee"] = groupAssignee;
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.execute(document);
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your help. I've add this script in "data dictionnary /scripts" and use it with a content rule. Managers don't have any notification on their dashbord and I've got no errors. Which tool(s) can I use to test this script ? or debug it ?
use Florian's Alfesco JS Console: github.com/share-extras/js-console If this script is executed outside of a rule, then you'll have to define the document variable yourself, e.g. var document = utils.getNodeFromString(yourNodeRefString);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.