on 12-25-2015 7:04 AM
Hello,
The job is scheduled every weekend to send the notification mails to the BPM task creator. And the program use as reference the CE Table currently.
Now the new requirements is to change the logic of who receive the notifications. The mail should be sent to the actual owner of the task. How can I get the task actual owner? I checked the thread but I don't know how to use it in ejb program. Please advise. Thanks a lot.
Piece of codes:
@Override
public void onJob(JobContext ctx) throws Exception {
String processName = null;
Logger logger = ctx.getLogger();
logger.info("Job started OK");
int delayedTasks = 0;
try {
ejbService = EJBService.getInstance();
userCtx = PdsConnection.connect(null);
JobParameter nameParameter = ctx.getJobParameter("BpmProcessName");
if (nameParameter != null) {
processName = nameParameter.getStringValue();
}
if (processName == null || processName.isEmpty()) {
logger.info("Specify a process name in the BpmProcessName parameter.");
return;
}
if(!isWeekend()){
//Notifications for rejections
List<ProcessDTO> openRejections = getOpenRejections();
for(ProcessDTO processDTO : openRejections){
messageType = REJECTION_STANDARD_EMAIL;
sendRejectionEmail(processDTO);
delayedTasks++;
}
//Notifications for draft request
List<RequestDTO> draftRequests = getDraftRequests();
messageType = DRAFT_REQUEST_EMAIL;
for(RequestDTO requestDTO : draftRequests){
sendEmail(requestDTO);
delayedTasks++;
}
}
JobParameter lengthParameter = ctx.getJobParameter("NumberOfDelayedTasks");
lengthParameter.setIntegerValue(delayedTasks);
ctx.setJobParameter(lengthParameter);
} catch (Exception e) {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(bout);
e.printStackTrace(ps);
logger.info(new String(bout.toByteArray()));
handleError(e);
}finally{
if(ejbService != null){
try{
ejbService.closeContext();
}catch (Exception e) {}
if(userCtx != null) {
SessionManager.getInstance().destroySessions(userCtx);
}
}
}
private void sendEmail(RequestDTO requestDTO){
try{
List<String> to = pmFromRequest(requestDTO.getCreatedBy());
List<String> cc = getProgramManager();
MailUtils.sendMailWithAttachment(getSubject(""+requestDTO.getId()), getMessage(), getSenderEmail(),
convertListToArray(to), convertListToArray(cc), null, null, null);
}catch (Exception e) {
handleError(e);
}
}
Happy holidays!
Justin
Please kindly help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Justin,
First of all there is no BPM API in CE 7.2
I assume there is a CEDB table where you have the list of potential owners stored to whom the notification is being sent through the Job.
So a new column needs to be created in your table which will be a flag that marks a potential owner as actual owner.
Now you can get the actual owner of the task by doing the below mapping in your process.
Note that this will not work for In Progress tasks.
Best Regards,
Rohit
Hi Justin,
If you are using SAP CE 7.3 then BPM API directly gives the actual owner.
First you can get the "TaskInstanceManager" instance from BPMFactory.
Below code might work for you.
TaskInstanceManager tm = BPMFactory.getTaskInstanceManager();
TaskDetail td= tm.getTaskDetail(new URI("bpm://bpm.sap.com/task-instance/" + taskInstanceId));
td.getActualOwner() gives the actual owner of the task.
Best Regards,
Rohit
Hello there,
Can anybody help on this question? Appreciate your time and efforts.
Happy New Year!
Regards,
Justin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.