Hi,
I trying sending email to human task candidates user, and tried this codes:
1.
import org.ow2.bonita.util.AccessorUtil def candidates = AccessorUtil.getQueryRuntimeAPI().getTaskCandidates(activityInstance.getUUID()) def to=“” for(user in candidates){ if(to!=“”) to+=“,” // If Emails are not stored in Bonita User Experience, please adapt the next line to get email from your system to+=AccessorUtil.getIdentityAPI().getUser(user).getEmail() } return to
import org.bonitasoft.engine.api.ProcessRuntimeAPI;
import java.util.logging.Logger;
import java.lang.StringBuilder;
import org.bonitasoft.engine.api.IdentityAPI;
import org.bonitasoft.engine.identity.ContactData;
int dI = 0;
boolean debug = true;
StringBuilder logWrite = new StringBuilder();
Logger logger = Logger.getLogger(“org.bonitasoft”);
ProcessRuntimeAPI processRuntimeAPI = apiAccessor.getProcessAPI();
logWrite.append(“\n\n”);
//set the name of the routine
logWrite.append("Process Name: "+ processRuntimeAPI.getProcessInstance(processInstanceId).getName());
logWrite.append(“\n\t” + dI++ + “Trace Start”);
//TODO - Code goes in here - START
String bonUser = “walter.bates”;
String toEmails = “”;
def identityAPI = apiAccessor.getIdentityAPI();
def theUser = apiAccessor.getIdentityAPI().getUserByUserName(bonUser.toLowerCase());
if(theUser!=null){
logWrite.append(“\n\t” + dI++ + “contact found”);
// To have professional email
ContactData professionalData = identityAPI.getUserContactData(theUser.getId(), false);
String professionalEmail = professionalData.getEmail();
if (professionalEmail != null && !professionalEmail.isEmpty()) {
logWrite.append(“\n\t” + dI++ + “professionalEmail: “+professionalEmail);
toEmails = professionalEmail;
logWrite.append(”\n\t” + dI++ + toEmails);
}
else{
logWrite.append(“\n\t” + dI++ + “contact NOT found”);
return “contact NOT found”;
}
}
logWrite.append(“\n\t” + dI++ + “Trace End”);
logWrite.append(“\n\n”);
if(debug){logger.severe(logWrite.toString())}
return toEmails;
So this is my problem, I am getting below error repeatedly for every solution:
org.restlet.Component.BonitaRestletApplication Exception or error caught in server resource
org.bonitasoft.engine.bpm.process.ProcessInstanceNotFoundException: USERNAME=***** | Archived Process Instance not found [TASK ID]
and I stuck here please guide me.
Thank you all.