I’m in the process of writing a BPM that emails upper management if an Employee’s Pay Rate has been changed. I have a data directive that works (using the “ttPREmpRt.PayRate field has been changed from any to another” condition). The only issue is that it doesn’t show the employee’s name, because it isn’t stored in the PREmpRt table, only the EmpLink is. I’m trying to include the PREmpMas table, but aren’t sure how to do so. I’ve also tried a method directive on the “PREmployee.Update” method since it includes the ttPREmpRt & ttPREmpMas tables, but have not been able to accomplish what I’m trying to do.
Does anyone have any ideas or guidance they could provide on how to get the “Name” field from the PREmpMas table into this email?
As always, I appreciate any help or suggestions provided!
Hey Andrew, thanks for taking the time here.
I don’t use C# very often in my role, it’s something I’m still working towards learning.
I added an “Execute Custom Code” widget in my data directive, and it looks like I’m missing an assembly, would it be Erp.Contracts.BO.PREmployee?
Would you mind elaborating on how you would do this?
First I would create a Variable called ‘EmployeeName’, to store the employee name, which you can use later for your email notification.
Then, in the Custom Code widget:
// Get the first row from the ttPREmpRt temporary table.
var employeeRate = ttPREmpRt.First();
// Get the employee master record from the database where the EmpLink value matches the employee rate record. Store the value in the 'EmployeeName' variable for later use.
var employee = Db.PREmpMas.FirstOrDefault(emp => emp.Company == employeeRate.Company && emp.EmpLink == employeeRate.EmpLink);
// Get the 'Name' value from the Employee master record. If no record was found for some reason, default to 'Unknown'.
EmployeeName = employee?.Name ?? "Unknown";