<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Need help with workflow in Alfresco
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/sgartner">Scott Gartner</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/539315#539315">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hello jBPM community,</p><p>I haven't had any luck getting help in the Alfresco forums, and I'm hoping for more here.&#160; We are building an application based on Alfresco and jBPM and I have defined a workflow, but I have either defined it wrong or am missing something or there are bugs in Alfresco integration with jBPM and I need help figuring out which and fixing it.&#160; Here is the problem:</p><p>I have an advanced workflow and I am trying to launch it from JavaScript.&#160; Here is the code I'm using to start the workflow:&#160;&#160; {code} var nodeId = args.nodeid; var document = search.findNode("workspace://SpacesStore/" + nodeId); var workflowAction = actions.create("start-workflow"); workflowAction.parameters.workflowName = "jbpm$nmwf:MyWorkflow"; workflowAction.parameters["bpm:workflowDescription"] = "Please edit: " + document.name; workflowAction.parameters["bpm:assignees"] = [people.getPerson("admin"), people.getPerson("andyg")]; var futureDate = new Date(); futureDate.setDate(futureDate.getDate() + 7); workflowAction.parameters["bpm:workflowDueDate"] = futureDate; workflowAction.execute(document); {code}</p><p>This runs fine and e-mail sent from the start node's default transition fires just fine.&#160; However, when I go looking for the workflow in my task list it is not there, but it is in my *completed* task list.&#160; The default transition (the only transition) from the start node points at a task node which has four transitions.</p><p>There are 8 tasks and 22 transitions in the workflow.&#160; When I use the workflow console to start the workflow and end the start task, it properly follows the default start node transition to the next task.&#160; The new task shows up in "show tasks" but does not show up in "show my tasks" (apparently because the task was marked completed for some reason, though it is not in the "end" node).&#160; The task is:</p><p>{quote}task id: jbpm$111 , name: nmwf:submitInEditing , properties: 18{quote}</p><p>If I do "show transitions" it looks just as I would expect:</p><p>{quote} path: jbpm$62-@ , node: In Editing , active: true&#160; task id: jbpm$111 , name: nmwf:submitInEditing, title: submitInEditing title , desc: submitInEditing description , properties: 18&#160; transition id: Submit for Approval , title: Submit for Approval&#160; transition id: Request Copyediting Review , title: Request Copyediting Review&#160; transition id: Request Legal Review , title: Request Legal Review&#160; transition id: Request Review , title: Request Review {quote}</p><p>I don't want to post the entire workflow as it's large, but here are the first two nodes:</p><p>First the swimlanes: {code}&#160;&#160;&#160;&#160; &lt;swimlane name="initiator"&gt;&lt;/swimlane&gt;&#160;&#160;&#160;&#160; &lt;swimlane name="Content Providers"&gt;&#160;&#160;&#160;&#160;&#160;&#160; &lt;assignment actor-id="Content Providers"&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;actor&gt;#{bpm_assignees}&lt;/actor&gt;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/assignment&gt;&#160;&#160;&#160;&#160; &lt;/swimlane&gt; {code}</p><p>Now the nodes: {code}&#160;&#160;&#160;&#160; &lt;start-state name="start"&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;task name="nmwf:submitTask" swimlane="initiator"/&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;transition name="" to="In Editing"&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;action&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;runas&gt;admin&lt;/runas&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;script&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; /* Code to send e-mail that a new workflow was started.&#160; I get this e-mail. */&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/script&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/action&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/transition&gt;&#160;&#160;&#160;&#160; &lt;/start-state&gt;&#160;&#160;&#160;&#160; &lt;task-node name="In Editing"&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;task name="nmwf:submitInEditing" swimlane="Content Providers" /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;!-- I put e-mail sending code in each of these transitions, but none are firing. --&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;transition to="In Approval" name="Submit for Approval"&gt;&lt;/transition&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;transition to="In Copyediting" name="Request Copyediting Review"&gt;&lt;/transition&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;transition to="In Legal Review" name="Request Legal Review"&gt;&lt;/transition&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;transition to="In Review" name="Request Review"&gt;&lt;/transition&gt;&#160;&#160;&#160;&#160; &lt;/task-node&gt; {code}</p><p>Here is the model for these two nodes: {code}&#160;&#160;&#160;&#160;&#160; &lt;type name="nmwf:submitTask"&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;parent&gt;bpm:startTask&lt;/parent&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;mandatory-aspects&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;aspect&gt;bpm:assignees&lt;/aspect&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/mandatory-aspects&gt;&#160;&#160;&#160;&#160;&#160; &lt;/type&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;type name="nmwf:submitInEditing"&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;parent&gt;bpm:workflowTask&lt;/parent&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;mandatory-aspects&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;aspect&gt;bpm:assignees&lt;/aspect&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/mandatory-aspects&gt;&#160;&#160;&#160;&#160;&#160; &lt;/type&gt; {code}</p><p><span>Here is a pseudo-log of running the workflow in the workflow console: {quote} :: deploy alfresco/extension/workflow/processdefinition.xml&#160; deployed definition id: jbpm$69 , name: jbpm$nmwf:MyWorkflow , title: nmwf:MyWorkflow , version: 28&#160; :: var bpm:assignees* person admin,andyg&#160; set var {</span><a class="jive-link-external-small" href="http://www.alfresco.org/model/bpm/1.0" target="_blank">http://www.alfresco.org/model/bpm/1.0</a><span>}assignees = [workspace://SpacesStore/73cf1b28-21aa-40ca-9dde-1cff492d0268, workspace://SpacesStore/03297e91-0b89-4db6-b764-5ada2d167424]&#160; :: var bpm:package package 1&#160; set var {</span><a class="jive-link-external-small" href="http://www.alfresco.org/model/bpm/1.0" target="_blank">http://www.alfresco.org/model/bpm/1.0</a><span>}package = workspace://SpacesStore/6e2bbbbd-b728-4403-be37-dfce55a83641&#160; :: start bpm:assignees bpm:package&#160; started workflow id: jbpm$63 , def: nmwf:MyWorkflow path: jbpm$63-@ , node: start , active: true&#160; task id: jbpm$112 , name: nmwf:submitTask, title: submitTask title , desc: submitTask description , properties: 16&#160; transition id: [default] , title: Task Done&#160; :: show transitions&#160; path: jbpm$63-@ , node: start , active: true&#160; task id: jbpm$112 , name: nmwf:submitTask, title: submitTask title , desc: submitTask description , properties: 17&#160; transition id: [default] , title: Task Done&#160; :: end task jbpm$112&#160; signal sent - path id: jbpm$63-@ path: jbpm$63-@ , node: In Editing , active: true&#160; task id: jbpm$113 , name: nmwf:submitInEditing, title: submitInEditing title , desc: submitInEditing description , properties: 17&#160; transition id: Submit for Approval , title: Submit for Approval&#160; transition id: Request Copyediting Review , title: Request Copyediting Review&#160; transition id: Request Legal Review , title: Request Legal Review&#160; transition id: Request Review , title: Request Review&#160; :: show tasks&#160; task id: jbpm$113 , name: nmwf:submitInEditing , properties: 18&#160; :: show my tasks&#160; admin:&#160; [there is no output here] {quote}</span></p><p>I have been making the assumption that the bpm:assignees that I am setting before starting the workflow initially are getting passed to the first task node "In Editing".&#160; Clearly the assignees are on the task object and not on the workflow object.&#160; I added the assignees aspect to the start-state task so that it could hold them (after I had a problem; initially they were not there) and possibly they are still sitting there, but the start-state has ended before I even get control back from the web script (not that it would help if it wasn't ended, I need it to be in "In Editing" as the start-state is only used to log that the workflow was started). </p><p>It has always confused me that the properties that I need to set on each task need to be requested before the task is entered (when you choose a transition you must provide the data for the next task before you can actually move to the next task as you have to validate that you have all of the required data [b]first[/b] and then signal the transition).&#160; However, the code to start the workflow is asynchronous and therefore does not return either the started workflow or the current task (which in my case would be "In Editing").&#160; So, either way you cannot set variables such as bpm:assignees and bpm:dueDate. </p><p>I wonder if this is the problem with the user task list.&#160; I'm setting the assignees in the property list, but maybe those assignees are going to the start-state task and are not getting passed to the "In Editing" task?</p><p>Note that this *is* my first jBPM workflow, so please don't assume I know what I'm doing.&#160; If you see something that looks off, it probably is and I just don't know it.</p><p>Thanks in advance for any advice or help,</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/539315#539315">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>