07-31-2009 02:30 PM
<node name="start-review">
<action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
<foreach>#{lexicon.selectPooledPublishers(bpm_package.children[0])}</foreach>
<var>publishers</var>
</action>
<transition name="review" to="review" />
</node>
<task-node name="review">
<task name="lexwf:reviewTask">
<assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
<pooledactors>#{publishers}</pooledactors>
</assignment>
</task>
<transition name="reject" to="handle-remarks" />
<transition name="approve" to="end-review" />
</task-node>
author publisher
=================================
1. new/modify concept
2. reject
3. modify concept
4. reject
5. modify concept
org.alfresco.scripts.ScriptException: Failed to execute supplied script: ReferenceError: "bpm_package" is not defined. (AlfrescoScript#1)
08-01-2009 04:10 AM
08-03-2009 02:40 AM
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="lexwf:approval">
<!– SWIMLANES –>
<swimlane name="initiator" />
<!– No swimlane for publisher(s). These are assigned by a for-each fork –>
<!– WORKFLOW STEPS –>
<!– The starting state –>
<start-state name="start">
<description>Request an approval for a business concept</description>
<task name="lexwf:requestApprovalTask" swimlane="initiator" />
<transition name="start-review" to="start-review">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
//The selectPooledPublishers function returns an object (array actually) suitable for using in a pooledactors assignment.
// But here the result is just used to know which publishers should receive a mail.
var pubs = lexicon.selectPooledPublishers(bpm_package.children[0]);
var toMail = new Array();
// …
// Here 'toMail' gets filled with some unique usernames, depending on the contents of 'pubs'. I removed this part of the code because it's a bit lengthy and not really interesting.
// …
var mail = actions.create("mail");
mail.parameters.to_many = toMail;
mail.parameters.subject = "Business Concept approval: " + bpm_package.children[0].properties["cm:title"];
mail.parameters.from = initiator.properties["cm:email"];
mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/lexicon/lexicon_notify_publisher.ftl");
mail.parameters.text = "Request for business concept approval";
mail.execute(bpm_package.children[0]);
</script>
</action>
</transition>
</start-state>
<!– The start-review node selects the publishers needed to publish the associated business concept. Upon
entering the node a counter that keeps track of the approval count is set to 0 to ensure that both new and
previously rejected concepts are forced to be reviewed by 1 publisher for each domain again. –>
<node name="start-review">
<action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
<foreach>#{lexicon.selectPooledPublishers(bpm_package.children[0])}</foreach>
<var>publishers</var>
</action>
<event type="node-enter">
<script>
<variable name="approveCount" access="read,write"/>
<expression>
approveCount = 0;
</expression>
</script>
</event>
<transition name="review" to="review" />
</node>
<task-node name="review">
<task name="lexwf:reviewTask">
<assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
<pooledactors>#{publishers}</pooledactors>
</assignment>
</task>
<transition name="reject" to="handle-remarks">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<expression>
// rejectItem is a function that does nothing more than set a rejected aspect with some properties on a node.
lexicon.rejectItem(bpm_package.children[0], lexwf_comment);
</expression>
<variable name="bpm_package" access="read" />
<variable name="lexwf_comment" access="read" />
</script>
</action>
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<expression>
var mail = actions.create("mail");
mail.parameters.to = initiator.properties["cm:email"];
mail.parameters.subject = "RE: Business Concept approval: " + bpm_package.children[0].properties["cm:title"];
var from = "alfresco@euroconsumers.com";
if(bpm_package.children[0].hasAspect("lex:rejected")) {
from = bpm_package.children[0].properties["lex:rejectedBy"].properties["cm:email"];
}
mail.parameters.from = from;
mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/lexicon/lexicon_notify_author.ftl");
mail.parameters.text = "Request for business concept approval";
mail.execute(bpm_package.children[0]);
</expression>
<variable name="initiator" access="read" />
<variable name="bpm_package" access="read" />
<variable name="companyhome" access="read" />
</script>
</action>
</transition>
<transition name="approve" to="end-review">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<expression>
approveCount = approveCount + 1;
// the publisherApproveItem function just sets some properties on a node to keep track of who approved the concept.
lexicon.publisherApproveItem(bpm_package.children[0], lexwf_comment);
</expression>
<variable name="approveCount" access="read,write" />
<variable name="bpm_package" access="read" />
<variable name="lexwf_comment" access="read" />
</script>
</action>
</transition>
</task-node>
<join name="end-review">
<transition to="is-approved" />
</join>
<decision name="is-approved">
<transition name="approved" to="end">
<condition>lexwf_approveCount > bpm_package.children[0].properties["lex:domainCategories"].length</condition>
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<runas>admin</runas>
<script>
<expression>
// The approveItem function removes and adds some aspects & properties on a node and checks in the node.
bpm_package.children[0] = lexicon.approveItem(bpm_package.children[0]);
</expression>
<variable name="bpm_package" access="read" />
<variable name="initiator" access="read" />
</script>
</action>
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
var mail = actions.create("mail");
mail.parameters.to = initiator.properties["cm:email"];
mail.parameters.subject = "RE: Business Concept approval: " + bpm_package.children[0].properties["cm:title"];
var from = "alfresco@euroconsumers.com";
if (bpm_package.children[0].hasAspect("lex:published")) {
from = bpm_package.children[0].properties["lex:publishedBy"][bpm_package.children[0].properties["lex:publishedBy"].length - 1].properties["cm:email"];
}
if (bpm_package.children[0].hasAspect("lex:removed")) {
from = bpm_package.children[0].properties["lex:removedBy"][bpm_package.children[0].properties["lex:removedBy"].length - 1].properties["cm:email"];
}
mail.parameters.from = from;
mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/lexicon/lexicon_notify_author.ftl");
mail.parameters.text = "Request for business concept approval";
mail.execute(bpm_package.children[0]);
</script>
</action>
</transition>
<transition name="not-approved" to="start-review" />
</decision>
<task-node name="handle-remarks">
<description>Initiator (author) needs to handle the remarks</description>
<task name="lexwf:handleRemarksTask" swimlane="initiator" />
<transition name="request-review" to="start-review">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript"> <!– Resend the mail –>
<script>
<expression>
var pubs = lexicon.selectPooledPublishers(bpm_package.children[0]);
var toMail = new Array();
// …
// Here 'toMail' gets filled with some unique usernames, depending on the contents of 'pubs'. I removed this part of the code because it's a bit lengthy and not really interesting.
// …
var mail = actions.create("mail");
mail.parameters.to_many = toMail;
mail.parameters.subject = "Business Concept approval: " + bpm_package.children[0].properties["cm:title"];
mail.parameters.from = initiator.properties["cm:email"];
mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/lexicon/lexicon_notify_publisher.ftl");
mail.parameters.text = "Request for business concept approval";
mail.execute(bpm_package.children[0]);
</expression>
<variable name="initiator" access="read" />
<variable name="bpm_package" access="read" />
<variable name="companyhome" access="read" />
</script>
</action>
</transition>
</task-node>
<end-state name="end" />
<event type="process-end" />
</process-definition>
08-03-2009 09:55 AM
<join name="reject-join">
<event type="node-enter">
<script>
node.nOutOfM = 1;
</script>
</event>
<transition to="handle-remarks" />
</join>
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.