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

Notifications

Announcements

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

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 843 Super User 2025 Season 2

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 843 Super User 2025 Season 2

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 412 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans