How to send emails to Users of specific Roles

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

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,

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

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.

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 !

Hi,
Thanks for the help (even if it wasn’t for me in the first place :slight_smile: ).
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,

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

→ return getPossibleUsersOfHumanTaskong(processDefinitionId,‘Step2’, 0,5);

Regards

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

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,

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…

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 professionalEmails = new ArrayList(users.size());
for(final User user : users){

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

}

return professionalEmails;

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

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