web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Using a dynamic mapping in Business Process Task for email template

(0) ShareShare
ReportReport
Posted on by

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, 

I have the same question (0)
  • huijij Profile Picture
    19,811 on at

    Hi Ahsan,

    You may try to insert the code in the way to get a better view: Use rich formatting > insert > code

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 510 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 399

#3
Adis Profile Picture

Adis 251 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans