Flagging Checks with the Default Employee Department

,

Hello all,

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:

Any thoughts on how to accomplish my goal?

Any reason why you’re not making a company to company relationship in your code?

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.

How do I accomplish the goal?

Hi aarong, what could be causing the BPM to work only sometimes?

I made some changes.

   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

Please try again.

Did this resolve the problem?

Hi aarong, I was able to query the general ledger tables to get the costs I was looking for. Thank you for your time!