# BO BPM C# error trying to reference ttDMRCorAct.ShortChar01 **Category:** [Epicor ERP 10](https://www.epiusers.help/c/e10/5) **Created:** 2016-10-28 14:32 UTC **Views:** 1776 **Replies:** 6 **URL:** https://www.epiusers.help/t/bo-bpm-c-error-trying-to-reference-ttdmrcoract-shortchar01/35996 --- ## Post #1 by @DaveOlender I am trying to setup some C# code to send an email out when a CorrectiveAction field changes. I am trying to duplicate older ABL Code. So - When I try to save my DMRCorAct.Update BPM I get a compile error to points to not being able to find DMRCorAct.ShortChar01. I would appreciate a second set of eyeballs to see what I am missing. Here is the code I have right now: /* Send an email to the Corrective Action Champion when the Champion Field changes */ string strSendToAddress = string.Empty; string strSubjectMessage = string.Empty; string strBodyMessage = string.Empty; string strSentFromAddress = string.Empty; string strInitiatedByName = string.Empty; Erp.Tables.EmpBasic EmpBasic; foreach(var ttDMRCorAct_xRow in ttDMRCorAct) { var ttDMRCorActRow=ttDMRCorAct_xRow; if(ttDMRCorAct_xRow != null) { /* Lookup the Initiated by (DMRCorAct.AssignedTo) empl number in EmpBasic to lookup the email address */ EmpBasic=(from EmpBasic_Row in Db.EmpBasic where EmpBasic_Row.Company == ttDMRCorActRow.Company && EmpBasic_Row.EmpID == ttDMRCorActRow.AsigndTo select EmpBasic_Row).FirstOrDefault(); if(EmpBasic != null) { if(EmpBasic.EMailAddress.Length > 0) { strSentFromAddress = EmpBasic.EMailAddress; strInitiatedByName = "ERP Admin"; } else { strSentFromAddress = "ERP.Admin@watergrem.com"; strInitiatedByName = "ERP Admin"; } /* Lookup the Champion empl number in EmpBasic to lookup the email address */ EmpBasic=(from EmpBasic_Row in Db.EmpBasic where EmpBasic_Row.Company == ttDMRCorActRow.Company && EmpBasic_Row.EmpID == ttDMRCorActRow.ShortChar01 select EmpBasic_Row).FirstOrDefault(); if(EmpBasic != null) { if(EmpBasic.EMailAddress.Length > 0) { strSentFromAddress = EmpBasic.EMailAddress; strInitiatedByName = "ERP Admin"; } else { strSentFromAddress = "ERP.Admin@watergrem.com"; strInitiatedByName = "ERP Admin"; } } } } --- ## Post #2 by @josecgomez tt Tables do not have access to UD fields you have to use the accessors UDField("Name) and SetUDField("Name",value) --- ## Post #3 by @DaveOlender That so confuses me - because I setup an BPM show message and the ttDMRCorAct table has all the UD Fields and I can include the ShortChar01 and it shows the proper data. Also, I apologize for my C# ignorance - I do not understand your answer. Would I join the DMRCorAct_UD table and then assign the DMRCorAct_UD.ShortChar01 to a variable and then use that variable in my "where" section? Thanks, DaveO --- ## Post #4 by @josecgomez Show message and drag and drop tools understand this limitation so they take care of doing the "right" thing as needed. to access these fields in C# you need to use an accessor built in to the tt table so something like ```cs myTTRecord.UDField("MyField") // Will Return the value of the field myTTRecord.SetUDField("MyField",myValue); // Will Set it ``` --- ## Post #5 by @DaveOlender Mr. Jose: You are the man - I am constantly amazed at your knowledge. That worked - I had to convert the reference to a string before I could use it in the where section but it is working. I don't know how you ever figured out the ttDMRCorAct.UDField("ShortChar01") - but it works and I am grateful. Here is my solution: /* Send an email to the Corrective Action Champion when the Champion Field changes */ string strSendToAddress = string.Empty; string strSubjectMessage = string.Empty; string strBodyMessage = string.Empty; string strSentFromAddress = string.Empty; string strInitiatedByName = string.Empty; string strChampionEmpID = string.Empty; Erp.Tables.EmpBasic EmpBasic; foreach(var ttDMRCorAct_xRow in ttDMRCorAct) { var ttDMRCorActRow=ttDMRCorAct_xRow; if(ttDMRCorAct_xRow != null) { /* Lookup the Initiated by (DMRCorAct.AssignedTo) empl number in EmpBasic to lookup the email address */ EmpBasic=(from EmpBasic_Row in Db.EmpBasic where EmpBasic_Row.Company == ttDMRCorActRow.Company && EmpBasic_Row.EmpID == ttDMRCorActRow.AsigndTo select EmpBasic_Row).FirstOrDefault(); if(EmpBasic != null) { if(EmpBasic.EMailAddress.Length > 0) { strSentFromAddress = EmpBasic.EMailAddress; strInitiatedByName = "ERP Admin"; } else { strSentFromAddress = "ERP.Admin@watergrem.com"; strInitiatedByName = "ERP Admin"; } /* Lookup the Champion empl number in EmpBasic to lookup the email address */ strChampionEmpID = Convert.ToString(ttDMRCorActRow.UDField("ShortChar01")); EmpBasic=(from EmpBasic_Row in Db.EmpBasic where EmpBasic_Row.Company == ttDMRCorActRow.Company && EmpBasic_Row.EmpID == strChampionEmpID select EmpBasic_Row).FirstOrDefault(); if(EmpBasic != null) { if(EmpBasic.EMailAddress.Length > 0) { strSendToAddress = EmpBasic.EMailAddress; strInitiatedByName = "ERP Admin"; } else { strSendToAddress = "ERP.Admin@watergrem.com"; strInitiatedByName = "ERP Admin"; } } } //if(EmpBasic != null) } //if(ttDMRCorAct_xRow != null) --- ## Post #6 by @josecgomez Actually I had a formatting issue and the code didn't paste correctly, but I've corrected it now, if you go back to my response, you'll see you can tell the function the type (string) and then you do not need to conver it. Glad it works for you --- ## Post #7 by @Chris_Conn @DaveOlender - Jose is superhuman when it comes to Epicor code! --- **Canonical:** https://www.epiusers.help/t/bo-bpm-c-error-trying-to-reference-ttdmrcoract-shortchar01/35996 **Original content:** https://www.epiusers.help/t/bo-bpm-c-error-trying-to-reference-ttdmrcoract-shortchar01/35996