How to send emails to Users of specific Roles

1
0
-1

Good day,

I'm trying to use an email connector to send an email to Users included in a specific Role.

I tried using getPossibleUsersOfPendingHumanTask but it only works for Human Tasks with connectors. I need to have a Service Task which sends the email to actors of a specific role.

Can anyone help me on this?

Regards,

Alfred Ayson Consultant

Comments

Submitted by ronak on Tue, 04/22/2014 - 00:21

Hi, Please note that there is no actor associate with service task. It always executed by the system. Not sure what you are trying to do here but you can use operations previous task to get pending users and save it as variable. Your email connector can use that variable.

Let me know how it goes.. Ronak

Submitted by alfred.ayson on Tue, 04/22/2014 - 03:39

Hi ronak,

Maybe i was not clear in my description. What I would want to do is to send an email to the actors of a particular swimlane to inform them that they need to login and perform the task assigned to them.

I would want to get the email addresses of the actors/users in the swimlane especially if there are more than one .

Thank you.

Submitted by paul33 on Tue, 04/22/2014 - 09:51

Hi, I've asked the same question on : http://community.bonitasoft.com/answers/get-lane-actor-groovy but I still don't know how to do it. So I am interested if you find an answer !

1 answer

1
+3
-1
This one is the BEST answer!

Hi,

You can use the new implementation of getPossibleUsersOfHumanTaskong processDefinitionId, String humanTaskName, int startIndex, int maxResults) since 6.1 to get the paginated list of possible users of a user task. Then for each user you can call identityAPI.getUserWithProfessionalDetails(userId) to get each email address. You can achieve this goal in a groovy script.

HTH,

Comments

Submitted by paul33 on Tue, 04/22/2014 - 12:07

Hi, Thanks for the help (even if it wasn't for me in the first place :) ). I tried on Bonita Studio 6.2.3 : return getPossibleUsersOfHumanTaskong(processDefinitionId,Step2, 0,5); but I get a "depends on Step2 is neither defined in the script nor in dependencies". So how do we call a specific humanTaskName ? Regards,

Submitted by matthieu.chaffotte on Tue, 04/22/2014 - 12:12

add quotes around Step2 because in a groovy script step2 is considered as a variable

-> return getPossibleUsersOfHumanTaskong(processDefinitionId,'Step2', 0,5);

Regards

Submitted by paul33 on Tue, 04/22/2014 - 13:57

Thanks again ! I tried it but now, I have got : "No signature of method: Script1.getPossibleUsersOfHumanTaskong() is applicable for argument types: (java.lang.Long, java.lang.String, java.lang.Integer, java.lang.Integer) values: [9193000046765828276, Step2, 0, 5]" Do I miss an import or something else ? Regards

Submitted by matthieu.chaffotte on Tue, 04/22/2014 - 14:13

I made a mistake the signature is:

getPossibleUsersOfHumanTask(processDefinitionId,'Step2', 0,5);

I let 'ong' at the end of the method name

My apologizes, Regards,

Submitted by paul33 on Tue, 04/22/2014 - 14:23

Ok, I thought so as i couldn't find it in the javadoc ... So I already tried "return getPossibleUsersOfHumanTask(processDefinitionId,'Step2', 0,5);" but it gave me the same warning of "No signature of method"... Sorry if that's something stupid, i'm pretty new to Bonita...

Submitted by alfred.ayson on Wed, 04/23/2014 - 03:05

Here is what I did...I got this part of code also in this forum...I just saved the output into a list variable

import org.bonitasoft.engine.identity.User;
import org.bonitasoft.engine.identity.ContactData;
import org.bonitasoft.engine.bpm.actor.ActorCriterion;

// Get the users attached to the actor member of the human task
final List users = apiAccessor.processAPI.getPossibleUsersOfPendingHumanTask(activityInstanceId, 0, Integer.MAX_VALUE);

// Get the professional email of the users
final List<String> professionalEmails = new ArrayList<String>(users.size());
for(final User user : users){

ContactData contactData = BonitaUsers.getUserProfessionalContactInfo(apiAccessor,user.id);
professionalEmails.add(contactData.email);

}

return professionalEmails;
Submitted by paul33 on Wed, 04/23/2014 - 11:45

Thanks for the help. I did it but it only works on a human task ? didn't you try it on a service task ?

Submitted by paul33 on Wed, 04/23/2014 - 15:32

Thanks ! it works! I just changed the method by : getPossibleUsersOfHumanTask(processDefinitionId, "Step3", 0, Integer.MAX_VALUE);

Notifications