cancel
Showing results for 
Search instead for 
Did you mean: 

Default Assignee(s) in process definition

sebp
Champ in-the-making
Champ in-the-making
Is it possible to insert default assignee(s) in the processdefinition?

For example, if someone opens the manage task dialog for the following review task he should see the user 'martin' already entered as assignee.

<task-node name="review">
        <task name="pdwf:reviewTask" swimlane="Buero">
            <event type="task-create">
                <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                    <runas>admin</runas>
                    <script>
                        bpm_assignee = people.getPerson("martin");   
                    </script>
                </action>
            </event>
        </task>
        <transition to="terminierung" name="terminieren">
        </transition>
</task-node>

But the above code doesn't work.  Smiley Indifferent
5 REPLIES 5

sethatrothbury
Champ in-the-making
Champ in-the-making
Either put Martin into the Buero swimlane or just assign the task to them:


           <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
              <actor>martin</actor>
           </assignment>

sebp
Champ in-the-making
Champ in-the-making
Thanks for your reply. What I want is that Martin is the proposed actor for the next task. Therefore if the user opens the task dialog for the pdwf:reviewTask he sees Martin already assigned for the next task. But the user must be able to change the assignment. If I hard code Martin in the swimlane or in the task assighment then he will always be assigned to the task and that's not ok.

sethatrothbury
Champ in-the-making
Champ in-the-making
What you could do is set the bpm_assignee variable upon node-enter using a script inside the node. That way, the user's would see Martin, but would be able to remove him and add someone else in his stead. Something like…

      <event type="node-enter">
         <script>
            <variable name="bpm_assignee" access="write"/>
            <variable name="people" access="read"/>
            <expression>
               bpm_assignee = null;
                                        var assignee = people.getPerson("martin");
                                        bpm_assignee = assignee;
            </expression>
         </script>
       </event>

sebp
Champ in-the-making
Champ in-the-making
Thanks, it works now. I changed to javascript.  I put it in another event because I got errors using node-enter.


          <event type="task-assign">
                <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                    <runas>admin</runas>
                    <script>
                        <expression>
                            bpm_assignee = people.getPerson("martin");
                            logger.log("assignee is now: " + bpm_assignee);
                            bpm_assignee;
                        </expression>
                        <variable name="logger" access="read" />
                        <variable name="bpm_assignee" access="read,write" />
                    </script>
                </action>
            </event>

Now I tried to do the same with bpm_assignees. I realized that bpm_assignees is a collection so I tried to do:


bpm_assignees.removeAll();
people.getPerson("hans");

But the call for bpm_assignees.removeAll() creates an exception when the script is executed. And if I only do people.getPerson("hans") then after the script it complains that a JScriptNode cannot be cast ta a JBPMNode. I assume that getPerson("hans") returns a JScriptNode that is then entered into the bpm_assignees collection  :?: Anyway, I will keep trying.

krups
Champ in-the-making
Champ in-the-making
did get it work?