How can I get Manager Email Address of an Initiated user?

I created a process and I want to send an email to Manager after Initiator Form is completed, how can I send an email to Manager with Email connector?

You’ll have to write a small groovy script to do this :

// retrieve the initiator's manager's id long managerId = BonitaUsers.getProcessInstanceInitiatorManager(apiAccessor, processInstanceId).id; // get the manager's contact data ContactData contactData = BonitaUsers.getUserProfessionalContactInfo(apiAccessor, managerId); return contactData.email;

processInstanceId, managerId and apiAccessor are variables provided by Bonita.

I want Initiated user’s Manager Email Address, I tried with below but it is not working can you please have a look at it?

${import org.ow2.bonita.facade.IdentityAPI;
import org.ow2.bonita.facade.identity.User;
IdentityAPI api = apiAccessor.getIdentityAPI();
User user = api.findUserByUserName(processInstance.getStartedBy());

long managerId = BonitaUsers.getProcessInstanceInitiatorManager(apiAccessor, processInstanceId).id;
ContactData contactData = BonitaUsers.getUserProfessionalContactInfo(apiAccessor, managerId);
return contactData.email;
}

Hi,

I want really to know how to put bdm in the body of an email connector ?

Regards

Yassine

I want Initiated user’s Manager Email Address, I tried with below but it is not working can you please have a look at it?

${import org.ow2.bonita.facade.IdentityAPI;
import org.ow2.bonita.facade.identity.User;
IdentityAPI api = apiAccessor.getIdentityAPI();
User user = api.findUserByUserName(processInstance.getStartedBy());

long managerId = BonitaUsers.getProcessInstanceInitiatorManager(apiAccessor, processInstanceId).id;
ContactData contactData = BonitaUsers.getUserProfessionalContactInfo(apiAccessor, managerId);
return contactData.email;
}

The first 4 lines are not needed. Is it the whole script or just a part of it ? If this is the whole script it shouldn’t be wrapped in ${ }. I assumed you are familiar with programming languages. If you’re not let me know an I’ll provide more explanations.

Hi Yassine, Even I struck at this point…could you please comment here if you are able to fix it!

Ok no problem

Check this link Yassine, http://community.bonitasoft.com/questions-and-answers/send-email-task-assignee-task-name-link

I see the code there but I don’t know where i can put the script.

You have to use the script editor to build up your email body, something similar to this:

StringBuilder sb = new StringBuilder();

sb.append(“”);
sb.append(“”);
sb.append(“Dear ABC,
”);
sb.append(“BDM Field 1 = " + myBDM.getField1());
sb.append(“BDM Field 2 = " + myBDM.getField2());
sb.append(””);
sb.append(“”);

return sb.toString();

I am able to achieve it, by above method…

Can you help me on this?

How can I get BDM Values from Initiator form to Dept Manager Form
http://community.bonitasoft.com/questions-and-answers/how-can-i-get-bdm-values-initiator-form-dept-manager-form

I’m sorry but i don’t have any idea about this. if you didn’t find any solution in the end . I think you should to save the BDM Values form initiator in another data base and finally get them from.