cancel
Showing results for 
Search instead for 
Did you mean: 

get property owner

giorgio
Champ in-the-making
Champ in-the-making
What is the correct syntax to capture the value of the property cmSmiley Surprisedwner is the owner of the workflow, in order to assign a property of a file from the review_pooled_definition.xml, put an example in which I capture the name of the group and assigns it.

<task-node name="rejected">

        <transition name="" to="end" />
            <event type="node-enter">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
for (var z = 0; z &lt; bpm_package.children.length; z++)
{
bpm_package.children[z].properties["my:expert"] = bpm_groupAssignee.properties["usr:authorityName"];

bpm_package.children[z].save();
}
</script>
</action>
</event>
    </task-node>


What I want to know is how you would do this same thing for the property owner to take possession of the workflow and do it again when the workflow finishes.

I hope someone can help me because I have not found anything like this example. Thanks and regards.
10 REPLIES 10

cheffilet
Champ in-the-making
Champ in-the-making
I understand regarding ownership the "initiator". You should be able to accessing the initiator on unsing the "initiator" variable.

giorgio
Champ in-the-making
Champ in-the-making
I do not know if I understood you, you mean to attach the property Initiator, obtained the user name that has taken possession? and what the correct syntax?

cheffilet
Champ in-the-making
Champ in-the-making
I understand your issue as follows: You want to retrive the owner of the workflow. An owner is for me the initiator of the workflow that has been started that worfklow. So i guess this is what you want to retrieve. Therefore you should be able to obtain the initiator scripting variable like following:


<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
initiator.properties[ …. ]

giorgio
Champ in-the-making
Champ in-the-making
No no, I do not refer to the originator of the workflow, if the user takes possession in a pooled workflow type, which are for groups, but one of the users in the group takes possession of the workflow, then becomes the owner and appears on the taskbar dashlet active as an owner. you understand me?

thanks and regards.

cheffilet
Champ in-the-making
Champ in-the-making
Ah allright now i´ve understand.

I do not know whether its possible to retrieve the last task-node thas has been performed. As in your code-excerpt in post-1 you´re already in the next step.

In your previous task-node (where the user/actor performs some actions) you could add a new event being called "task-end" where you can retrieve the current task-owner and set it as a variable to the current workflow. But you have to scoping this variable as task-properties does not automatically passing such properties to the whole workflow.

You should add something like:


<event type="task-end">
   <script>
      var wf_parenttaskowner= taskInstance.actorId;
   </script>
   <controller>
      <variable name="wf_parenttaskowner" access="read, write" mapped-name="wf_parenttaskowner"/>
   </controller>
</event>

I´ve not tested but something like this should be working. But thats not an appropriated solution as we could have paraellel tasks so it doesnt works for it.

giorgio
Champ in-the-making
Champ in-the-making
I tried the following code, but the log of alfresco say "wf_parenttaskowner is not defined".

(you get the whole code review_pooled_processdefinition.xml), which is what I am doing wrong?

<?xml version="1.0" encoding="UTF-8"?>

<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wf:reviewpooled">

    <swimlane name="initiator" />

    <start-state name="start">
        <task name="wf:submitGroupReviewTask" swimlane="initiator" />
        <transition name="" to="review" />
    </start-state>

    <swimlane name="reviewer">
        <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
            <pooledactors>#{bpm_groupAssignee}</pooledactors>
        </assignment>   
    </swimlane>

    <task-node name="review">
        <task name="wf:reviewTask" swimlane="reviewer">
            <event type="task-create">
                <script>
                   if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
                   if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
                </script>
            </event>
            <event type="task-end">
               <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                  <script>
                     <variable name="bpm_assignee" access="write"/>
                     <expression>
                        if (taskInstance.actorId != null)
                           people.getPerson(taskInstance.actorId);
                        else
                           person;
                     </expression>
            var wf_parenttaskowner= taskInstance.actorId;

                  </script>
                     <controller>
                          <variable name="wf_parenttaskowner" access="read, write" mapped-name="wf_parenttaskowner"/>
                     </controller>
               </action>
            </event>
        </task>
        <transition name="" to="completed" />
    <event type="node-enter">
<!– Update the status to Rejected when we enter this task –>
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
for (var i = 0; i &lt; bpm_package.children.length; i++)
{

bpm_package.children.properties["mySmiley Tonguerioridad"] = bpm_workflowPriority;
bpm_package.children.properties["my:estado"] = "Pendent";
bpm_package.children.properties["my:tecnico"] = wf_parenttaskowner;
bpm_package.children.save();
}
</script>
</action>
</event>
    </task-node>



    <task-node name="completed">
    <event type="node-enter">
<!– Update the status to Aproved when we enter this task –>
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
for (var a = 0; a &lt; bpm_package.children.length; a++)
{
bpm_package.children[a].properties["mySmiley Tonguerioridad"] = bpm_workflowPriority;
bpm_package.children[a].properties["my:estado"] = "Acabat";
bpm_package.children[a].properties["my:tecnico"] = wf_parenttaskowner;
bpm_package.children[a].save();
}
</script>
</action>
</event>
        <transition name="" to="end" />
    </task-node>

    <end-state name="end" />

</process-definition>

pjcaracuel
Champ in-the-making
Champ in-the-making
Is before the controller o de var definition??

Regards  :lol:

giorgio
Champ in-the-making
Champ in-the-making
Ah allright now i´ve understand.

I do not know whether its possible to retrieve the last task-node thas has been performed. As in your code-excerpt in post-1 you´re already in the next step.

In your previous task-node (where the user/actor performs some actions) you could add a new event being called "task-end" where you can retrieve the current task-owner and set it as a variable to the current workflow. But you have to scoping this variable as task-properties does not automatically passing such properties to the whole workflow.

You should add something like:


<event type="task-end">
   <script>
      var wf_parenttaskowner= taskInstance.actorId;
   </script>
   <controller>
      <variable name="wf_parenttaskowner" access="read, write" mapped-name="wf_parenttaskowner"/>
   </controller>
</event>

I´ve not tested but something like this should be working. But thats not an appropriated solution as we could have paraellel tasks so it doesnt works for it.

Good, I autorrespondo myself, and post this in the forum for all those who serve, because although it was in front of the nose has cost enough to find this, thank you very much to all who have been helping me what they have been, giving me ideas to capture this property.

In the end it was so easy to use this syntax. In this way we get the owner of the workflow, since process_definition, in the case of the workflows of this type have pooled empty until we take possession of the task, what happens is still not how to capture this event in order to assign the property just in time to take possession, as now I can only assign when you finish the task, as I do in the process definition does not tell if someone knows how to capture the event of taking possession to do so at this time .

bpm_package.children . properties [ "my: tecnico"] = bpm_package.properties [ 'cm: owner'];


a greeting.

cheffilet
Champ in-the-making
Champ in-the-making
Hi giorgio,

sry for my late posting, im still busy at this time… but you got it by yourself 😉

Have a look to the task events: task-assign as well as the assignment-tag.


<task-node>

  <task>
    …
    <event type="task-assign">
       <action class="…. extends JBPMSpringActionHandler">
     </event>

Regards