Use UD field in BPM C# Code?

We have a field on our Order Entry form for “Entered For”, this is use when someone enters in a sales order for a one of our customer service team is out of the office.

I’m working on a Post-Proc method BPM that will email the customer. I’m having problems getting it to pull the Entered For field on OrderHed table. Which is then failing to pull the email address from the UserFile table.

Probably something obvious I’m missing but here is the code snip. EnteredFor & EnteredForEmailAddr are BPM variables used in the outbound email.

Erp.Tables.OrderHed dbOrderHed;   // Declare var
Erp.Tables.UserFile dbUserFile;   // Declare var

var dbOrderHed_Recs = (from dbOrderHed_Row in Db.OrderHed  
                    where dbOrderHed_Row.Company == Session.CompanyID
                    && dbOrderHed_Row.OrderNum == OrderNumBPM
                    select dbOrderHed_Row).FirstOrDefault();   
{
//    var ttOrderHed = dbOrderHed_Recs;
if (dbOrderHed_Recs != null)
{
    EnteredFor = dbOrderHed_Recs.udEnteredFor_c;
    
    foreach (var dbUserFile_Recs in (from dbUserFile_Row in Db.UserFile
                                    where dbUserFile_Row.DcdUserID == dbOrderHed_Recs.udEnteredFor_c
                                    select dbUserFile_Row))  
    {
//            var ttOrderDtlRow = dbUserFile_Recs;
        if (dbUserFile_Recs != null)
        {
            EnteredForEmailAddr = dbUserFile_Recs.EMailAddress;
        }
    } // UserFile
} 
} //OrderHed

You have to use something like dbOrderHed_Recs[“udEnteredFor_c”] for UD fields

1 Like

Yeah, I’ve seen that in form code dbOrderHed_Recs[“udEnteredFor_c”] didn’t work here still but the solution was more easy in my case. The ud field already contained the users name ie JDoe, so all I had to do was put "@companyname.com" in the email widget To field and it concatenates properly to send the email.