send an email to a user for next task

1
0
-1

Hi i've been trying to send an email for a user to the next task what i did was this create a list variable and then created a script

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> operations_manager = new ArrayList<String>(users.size());
for(final User user : users){
 
ContactData contactData = BonitaUsers.getUserProfessionalContactInfo(apiAccessor,user.id);
if (contactData!=null && contactData.getEmail()!=null && !contactData.getEmail().isEmpty()) {
       
operations_manager.add(contactData.email);}

 }
 
return operations_manager

but i keep getting this error

java.lang.reflect.InvocationTargetException
org.bonitasoft.engine.bpm.connector.ConnectorExecutionException: org.bonitasoft.engine.core.connector.exception.SConnectorException: org.bonitasoft.engine.expression.exception.SInvalidExpressionException: Declared return type class java.lang.Long is not compatible with evaluated type class java.lang.Integer for expression activityInstanceId

can someone please help? i'm using latest version bonitasoft 6.3.2

2 answers

1
0
-1

Hi, you can get emails following way

getCurrentUserEmail

def email = BonitaUsers.getUserProfessionalContactInfo(apiAccessor, taskAssigneeId).email
return email`

getSpecificGroupEmails

import org.bonitasoft.engine.identity.ContactData
import org.bonitasoft.engine.identity.Group
import org.bonitasoft.engine.identity.User
import org.bonitasoft.engine.identity.UserCriterion
   
    Group groupSelected=apiAccessor.getIdentityAPI().getGroupByPath("/GROUP_PATH_IN_YOUR_ORGANIZATION")
    List<User> usersInGroup=apiAccessor.getIdentityAPI().getUsersInGroup(groupSelected.getId(), 0, 100, UserCriterion.FIRST_NAME_ASC)
    StringBuilder sb=new StringBuilder()
    for (User user:usersInGroup){
           //get professional contact data
           ContactData contactData = apiAccessor.getIdentityAPI().getUserContactData(user.getId(), false)
                if (contactData!=null && contactData.getEmail()!=null && !contactData.getEmail().isEmpty()){
                   sb.append(contactData.getEmail()).append(",")
         }
    }
    return sb.toString()

Hope it helps :)

1
0
-1

Hi,

the error seems not related to the specified script.

Please check the Return type of your scripts and validate that the return types are correct.

It might occur when you are trying to initialize the activityInstanceId variable which is not of correct type.

Regards,

Comments

Submitted by claudy991 on Wed, 09/03/2014 - 21:15

Hi thank you for your response but return type it's disabled and i cannot change it and everytime i try to use activityinstanceId i get the same error i recorded a video with it's current behavior http://screencast-o-matic.com/watch/c2QeqInP5G can you please help :( i've been stuck with this for a while now

Submitted by aurelien.pupier on Thu, 09/04/2014 - 08:43

Hi,

did you defined you rown variable activityInstanceId or are you using the provided one by Bonita?

Regards,

Submitted by claudy991 on Thu, 09/04/2014 - 08:49

im using the one provided by bonita

Notifications