
Hi all,
I'm working on Business Process Task functionality, in which I'm adding multiple tasks which are assigned to a Worker and sending them in email when we start the process.
The issue is that when email is sent, only last task populating in the Mapping is sent in the email template.
I want to know if there is a way we can populate the mappings dynamically. So that all the tasks are sent in the email.
Please, let me know
here is the code:
public static void sendNotification(RefRecId _header)
{
Map mappings = new Map(Types::String, Types::String);
BusinessProcessHeader header = BusinessProcessHeader::find(_header);
BusinessProcessTask task, taskUpd;
HcmWorker worker;
RefRecId emailRecId;
Description255 userEmail;
while select forupdate task
group by task.AssignedWorker, task.Name, worker.Person, worker.RecId
where task.ProcessHeader == header.RecId
&& task.AssignmentType == BusinessProcessAssignmentType::Worker
join worker
where worker.RecId == task.AssignedWorker
{
emailRecId = 0;
userEmail = CfzHRPBusinessProcessEmail::getUserEmail(worker.Person);
if(userEmail)
{
mappings.insert('name', worker.name());
mappings.insert('BusinessProcessNAme', header.Name);
mappings.insert('TaskName', task.Name);
mappings.insert('DueDate', date2Str(task.DueDate,213,DateDay::Digits2,DateSeparator::Slash,DateMonth::Digits2,DateSeparator::Slash,DateYear::Digits4));
emailRecId = CfzHRPEmailHelper::sendBusinessProcessEmailThroughSMTP(mappings, "Business_P", userEmail, "en-US");
if(emailRecId)
{
while select forupdate taskUpd
where taskUpd.ProcessHeader == header.RecId &&
taskUpd.AssignmentType == BusinessProcessAssignmentType::Worker &&
taskUpd.AssignedWorker == worker.RecId
{
ttsbegin;
taskUpd.CfzOutgoingEmail = emailRecId;
taskUpd.update();
ttscommit;
}
}
}
}
}
}
}
Regards,
Hi Ahsan,
You may try to insert the code in the way to get a better view: Use rich formatting > insert > code