cancel
Showing results for 
Search instead for 
Did you mean: 

send email to pooledactors

jwrobel
Champ in-the-making
Champ in-the-making
Hey Guys,
I'm trying to send out an email to notify a group of people that they have a task.

I've defined the group like so:

<swimlane name="office_managers">
   <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
      <pooledactors>#{people.getGroup('GROUP_office managers')}</pooledactors>
   </assignment>
</swimlane>

Once an invoice is received I want to notify them about it via email.

<node name="Recieve Invoice">
      <transition name="" to="Categorize">
         <!– email office managers about the invoice  –>
      </transition>
</node>

but as you can see I'm not really sure about how to go about it.

Thanks in advance,
Justin
6 REPLIES 6

vinaxwater
Champ in-the-making
Champ in-the-making

<transition to="submitView">
   <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 = "Memo Document Task " + bpm_workflowDescription;
                       mail.parameters.from = initiator.properties.email;
                       mail.parameters.text = "You have a new task from" + initiator;
                       mail.execute(bpm_package);
                }
      </script>
   </action>
</transition>

This is code for send mail to swimlane name is initiator. Hope will help for you.

jwrobel
Champ in-the-making
Champ in-the-making
Hey vinaxwater,
Thanks for your response! Unfortunetly, I'm still hitting some walls…

When I attempt to access my swimlane, like you illustrated, I get this error:


ERROR [org.jbpm.graph.def.GraphElement] action threw exception: Failed to execute supplied script: Failed to execute supplied script: ReferenceError: "office_managers" is not defined. (AlfrescoScript#1)

I tested it like so:

<node name="Recieve Invoice">
      <transition name="" to="Categorize">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               logger.log("here");
               var group = office_managers;
            </script>
         </action>
      </transition>
</node>


So my actual question is: How do I reference a swimlane in the processdefinition.xml file?

jwrobel
Champ in-the-making
Champ in-the-making
Okay, so I've been attempting to use groups defined in swimlanes in scripts.

Browsing in the forums a little more I stumbled upon this thread. It didn't solve my problem but it did give me an idea. I could assign a global var as the group and then just reference it when i need it!

Behold: processdefinition.xml

<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="helloWorld">
  <start-state name="start">
      <transition name="" to="Recieve Invoice"></transition>
   </start-state>

   <event type="node-enter">
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <script>
            <variable name="office_managers_group" access="write"/>
               <expression>
                  office_managers_group = people.getGroup('GROUP_office managers');
               </expression>
         </script>
      </action>
   </event>
  
   <swimlane name="office_managers">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment" >
         <pooledactors>#{office_managers_group}</pooledactors>
      </assignment>
   </swimlane>

   <node name="Recieve Invoice">
      <transition name="" to="Categorize">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
            <variable name="office_managers_group" access="read,write"/>
            <expression>
                 logger.log(office_managers_group);
   </expression>
            </script>
         </action>
      </transition>
   </node>

   <task-node name="Categorize">
      <task name="gwf:categorizeInvoice" swimlane="office_managers" />
         <transition to="end1" name="">
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                   <!– email person who completed task –>        
              </script>
           </action>   
        </transition>
   </task-node>  

   <end-state name="end1"></end-state>

</process-definition>

giafar
Champ in-the-making
Champ in-the-making
Hi,
take a look at my post. I think I have the solotion !
http://forums.alfresco.com/en/viewtopic.php?f=34&t=15824&p=51838#p51838

riogrande
Champ in-the-making
Champ in-the-making
I find a far easier way to do that.


         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <runas>admin</runas>
            <script>
               <expression>   
                  if (afwf_sendEmail)
                  {
                     for each (user in people.getMembers(people.getGroup('GROUP_TheGroupYouWant'), false)){
                        var mail = actions.create("mail");
                        mail.parameters.to = user.properties["cm:email"];
                        mail.parameters.subject = "File involved " + bpm_package.children[0].properties["cm:title"];
                        mail.parameters.from = initiator.properties["cm:email"];
                        mail.parameters.text = "Your message";
                        mail.execute(bpm_package);
                        if (logger.isLoggingEnabled()) {
                           logger.log("\nEmail send to " + user.properties['cm:firstName'] + " " + user.properties['cm:lastName']);
                        }                           
                     }
                  }                  
               </expression>
            </script>
         </action>

I recommend not to use variables (like <variable name="blabla" access="read,write">), there must be a problem with that. If you declare one variable has I wanted to do for the Group you will have an error for bpm_package that become undefined :roll:

riogrande
Champ in-the-making
Champ in-the-making
Have you an idea how to do the same but using a template for the email instead to hard code it ?
Getting started

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.