10-22-2013 10:31 AM
function startWorkflow(assigneeGroup)
{
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:parallelgroupreview";
workflow.parameters.requiredApprovePercent = 100;
workflow.parameters["bpm:workflowDescription"] = "Please review " + document.name;
workflow.parameters["bpm:assignees"] = [people.getPerson("boss"), people.getPerson("aaron")];
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.parameters["bpm:rejectDestination"] = "/sites/test/documentLibrary/C-Rejected-Updates-Needed"
workflow.parameters["bpm:aproveDestination"] = "/sites/test/documentLibrary/D-Final-Document"
workflow.parameters["sendEmailNotifications"] = true;
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 + "_SiteManager";
// 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();
<?xml version="1.0" encoding="utf-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wf:parallelgroupreview">
<swimlane name="initiator"></swimlane>
<start-state name="start">
<task name="wf:submitGroupReviewTask" swimlane="initiator" />
<transition name="" to="startreview" />
</start-state>
<node name="startreview">
<action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
<foreach>#{people.getMembers(bpm_assignees)}</foreach>
<var>reviewer</var>
</action>
<event type="node-enter">
<script>
<variable name="wf_approveCount" access="write" />
<expression>
wf_approveCount = 0;
</expression>
</script>
</event>
<transition name="review" to="review" />
</node>
<task-node name="review">
<task name="wf:reviewTask">
<assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
<actor>#{reviewer}</actor>
</assignment>
<event type="task-create">
<script>
if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
</script>
</event>
</task>
<transition name="approve" to="endreview">
<script>
<variable name="wf_approveCount" access="read,write" />
<expression>
wf_approveCount = wf_approveCount +1;
</expression>
</script>
</transition>
<transition name="reject" to="endreview" />
</task-node>
<join name="endreview">
<transition to="isapproved" />
</join>
<decision name="isapproved">
<event type="node-enter">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<variable name="wf_reviewerCount" access="write" />
<expression>people.getMembers(bpm_assignees).length;</expression>
</script>
</action>
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<variable name="wf_requiredPercent" access="write" />
<expression>wf_requiredPercent = wf_requiredApprovePercent;</expression>
</script>
</action>
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<variable name="wf_actualPercent" access="write" />
<expression>wf_actualPercent = ((wf_approveCount * 100) / people.getMembers(bpm_groupAssignee).length);</expression>
</script>
</action>
</event>
<transition name="reject" to="rejected" />
<transition name="approve" to="approved">
<condition>#{wf_actualPercent >= wf_requiredApprovePercent}</condition>
</transition>
</decision>
<task-node name="rejected">
<task name="wf:rejectedParallelTask" swimlane="initiator" />
<transition to="end">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
var dest = companyhome.childByNamePath(bpm_rejectDestination);
for (var i = 0; i < bpm_package.children.length; i++){
bpm_package.children.move(dest);
}
</script>
</action>
</transition>
</task-node>
<task-node name="approved">
<task name="wf:approvedParallelTask" swimlane="initiator" />
<transition to="end">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
var dest = companyhome.childByNamePath(bpm_aproveDestination);
for (var i = 0; i < bpm_package.children.length; i++){
bpm_package.children.move(dest);
}
</script>
</action>
</transition>
</task-node>
<end-state name="end" />
</process-definition>
10-23-2013 01:28 AM
<!– Submit review to multiple people (as included in a group) –>
<type name="wf:submitGroupReviewTask">
<parent>wf:submitConcurrentReviewTask</parent>
<mandatory-aspects>
<aspect>bpm:groupAssignee</aspect>
</mandatory-aspects>
</type>
10-23-2013 09:13 AM
function startWorkflow(assigneeGroup)
{
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:parallelgroupreview";
workflow.parameters.requiredApprovePercent = 100;
workflow.parameters["bpm:workflowDescription"] = "Please review " + document.name;
workflow.parameters["bpm:groupAssignee"] = people.getGroup( "GROUP_" + siteName + "_SiteManager");
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.parameters["bpm:rejectDestination"] = "/sites/test/documentLibrary/C-Rejected-Updates-Needed"
workflow.parameters["bpm:aproveDestination"] = "/sites/test/documentLibrary/D-Final-Document"
workflow.parameters["sendEmailNotifications"] = true;
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 + "_SiteManager";
// 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();
<?xml version="1.0" encoding="utf-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wf:parallelgroupreview">
<swimlane name="initiator"></swimlane>
<start-state name="start">
<task name="wf:submitGroupReviewTask" swimlane="initiator" />
<transition name="" to="startreview" />
</start-state>
<node name="startreview">
<action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
<foreach>#{people.getMembers(bpm_groupAssignee)}</foreach>
<var>reviewer</var>
</action>
<event type="node-enter">
<script>
<variable name="wf_approveCount" access="write" />
<expression>
wf_approveCount = 0;
</expression>
</script>
</event>
<transition name="review" to="review" />
</node>
<task-node name="review">
<task name="wf:reviewTask">
<assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
<actor>#{reviewer}</actor>
</assignment>
<event type="task-create">
<script>
if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
</script>
</event>
</task>
<transition name="approve" to="endreview">
<script>
<variable name="wf_approveCount" access="read,write" />
<expression>
wf_approveCount = wf_approveCount +1;
</expression>
</script>
</transition>
<transition name="reject" to="endreview" />
</task-node>
<join name="endreview">
<transition to="isapproved" />
</join>
<decision name="isapproved">
<event type="node-enter">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<variable name="wf_reviewerCount" access="write" />
<expression>people.getMembers(bpm_groupAssignee).length;</expression>
</script>
</action>
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<variable name="wf_requiredPercent" access="write" />
<expression>wf_requiredPercent = wf_requiredApprovePercent;</expression>
</script>
</action>
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<variable name="wf_actualPercent" access="write" />
<expression>wf_actualPercent = ((wf_approveCount * 100) / people.getMembers(bpm_groupAssignee).length);</expression>
</script>
</action>
</event>
<transition name="reject" to="rejected" />
<transition name="approve" to="approved">
<condition>#{wf_actualPercent >= wf_requiredApprovePercent}</condition>
</transition>
</decision>
<task-node name="rejected">
<task name="wf:rejectedParallelTask" swimlane="initiator" />
<transition to="end">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
var dest = companyhome.childByNamePath(bpm_rejectDestination);
for (var i = 0; i < bpm_package.children.length; i++){
bpm_package.children.move(dest);
}
</script>
</action>
</transition>
</task-node>
<task-node name="approved">
<task name="wf:approvedParallelTask" swimlane="initiator" />
<transition to="end">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
var dest = companyhome.childByNamePath(bpm_aproveDestination);
for (var i = 0; i < bpm_package.children.length; i++){
bpm_package.children.move(dest);
}
</script>
</action>
</transition>
</task-node>
<end-state name="end" />
</process-definition>
10-23-2013 10:42 AM
function startWorkflow(assigneeGroup)
{
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:parallelgroupreview";
workflow.parameters.requiredApprovePercent = 100;
workflow.parameters["bpm:workflowDescription"] = "Please review " + document.name;
// niketa - here siteName var would be undefined
//workflow.parameters["bpm:groupAssignee"] = people.getGroup( "GROUP_" + siteName + "_SiteManager");
workflow.parameters["bpm:groupAssignee"] = assigneeGroup
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.parameters["bpm:rejectDestination"] = "/sites/test/documentLibrary/C-Rejected-Updates-Needed"
workflow.parameters["bpm:aproveDestination"] = "/sites/test/documentLibrary/D-Final-Document"
workflow.parameters["sendEmailNotifications"] = true;
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 + "_SiteManager";
// 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);
//niketa - need to pass js group scriptNode object
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();
10-23-2013 11:17 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.