My end goal: to link a check number (Erp.PRCheck.CheckNum) to an employee’s department (erp.PREmpMas.JCDept).
I’ve tried moving the value from erp.PREmpMas.JCDept into an existing UD column Erp.PRCheck_UD.UDColumn when checks are posted using a BPM. The BPM is attached to Erp.BO.PayrollCheckEntry.Update method with the following code:
var PRCheck = (from row in ttPRCheck select row);
if (PRCheck != null) {
foreach (var r in PRCheck) {
string department = (from row in Db.PREmpMas where row.EmpID == r.EmpID select row.JCDept).FirstOrDefault();
r.SetUDField<System.String>("EmpJCDept_c", department);
} // end foreach
} //end if
The code works with some BPM triggers, but not all and I can’t figure out why. See evidence below:
No reason, but will improve by adding the relationship. We only have a single company under this app server and have decided to create new app servers for future acquisitions/companies.
var PRCheck = (from row in ttPRCheck select row);
if (PRCheck != null)
{
using (var txScope = IceContext.CreateDefaultTransactionScope())
{
foreach (var r in PRCheck) {
string department = (from row in Db.PREmpMas where row.Company == Session.CompanyID && row.EmpID == r.EmpID select row.JCDept).FirstOrDefault();
r.SetUDField<System.String>("EmpJCDept_c", department);
}
// end foreach
Db.Validate();
txScope.Complete();
}
} //end if