AnsweredAssumed Answered

<runas> in workflow

Question asked by fuad_gafarov on Jun 24, 2011
Hi.

I need run a little script in ad-hoc workflow.



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

<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wfl:lifecycleapproval">
  <swimlane name="initiator"/>

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

   <swimlane name="assignee">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{bpm_assignee}</actor>
      </assignment>
   </swimlane>
  
   <task-node name="adhoc">
      <task name="wf:adhocTask" swimlane="assignee">
         <event type="task-create">
              <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                <runas>admin</runas>
            <script>
          if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
               if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
                     bpm_package.children[i].properties["cm:name"] = "approved-document";
                     bpm_package.children[i].properties["cm:name"] = "alfresco_doc";
                     bpm_package.children[i].save();
                 </script>
             </action>
         </event>
      </task>
      <transition name="" to="completed">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <script>
              if (wf_notifyMe)
              {
                 var mail = actions.create("mail");
                 mail.parameters.to = initiator.properties.email;
                 mail.parameters.subject = "Adhoc Task " + bpm_workflowDescription;
                 mail.parameters.from = bpm_assignee.properties.email;
                 mail.parameters.text = "It's done";
                 mail.execute(bpm_package);
              }
           </script>
         </action>
      </transition>
   </task-node>
  
   <task-node name="completed">
      <task name="wf:completedAdhocTask" swimlane="initiator"/>
      <transition name="" to="end"/>
   </task-node>
     
   <end-state name="end"/>

</process-definition>





In this code fragment I make changes. Add runas and script for define name.

<task-node name="adhoc">
      <task name="wf:adhocTask" swimlane="assignee">
         <event type="task-create">
              <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                <runas>admin</runas>
            <script>
          if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
               if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
                     bpm_package.children[i].properties["cm:name"] = "approved-document";
                     bpm_package.children[i].properties["cm:name"] = "alfresco_doc";
                     bpm_package.children[i].save();
                 </script>
             </action>
         </event>
      </task>


But on execution this workflow I have - message.simple-workflow.failure
What's problem?
thank you.

Outcomes