Query a UDTable in E10

Good afternoon. I hopefully have an easily answered question. In E9 I have a simple query:

FIND FIRST OrderHed_UD WHERE OrderHed_UD.ForeignSysRowID = OrderHed.SysRowID EXCLUSIVE-LOCK NO-ERROR.

I can’t get this code to work in E10:

var OrderHed_UD = (from OrderHed_UD_Row in Db.OrderHed_UD
where OrderHed_UD_Row.ForeignSysRowID == OrderHed.SysRowID
select OrderHed_UD_Row).FirstOrDefault();

I keep getting the error “ErpContext does not contain a definition for OrderHed_UD and no accessible extension method ‘OrderHed_UD’ accepting a first argument of type ‘ErpContext’.” I assume OrderHed_UD isn’t in Db? I checked ExtUDMaint and my UD does exist. I feel like I’m missing something small…

Much health to you and yours!

Have you tried referencing the UD field from the main table?

OrderHed.MyColumn_c

Hello!

Well in E9 we had to add an OrderHed_UD table because we ran out of UDs to consume. So this UDTable was created in E9. Would the upgrade have consolidated all UDs into one table regardless of us using the OrderHed_UD table in E9?

use Db.OrderHed as it should contain the view that makes up OrderHed and OrderHed_UD, although some fields might need to be accessed by name like OrderHed_Row[“YourField_c”]

1 Like

if you have regenerated your database correctly, you never need to directly link the OrderHed_UD table. I have literally written 100s of BPMs that use UD Fields in E10 without doing this.

Example:

int myOrderNum = "1234";
//next line will retrieve the all the fields from OrderHed AND OrderHed_UD
var myOrderHed = Db.OrderHed.Where(x=>x.Company == CompanyID && x.OrderNum == myOrderNum).FirstOrDefault();

//next line would retrieve only specified fields from OrderHed AND OrderHed_UD (more efficient) myOrderHed2 will only have the three fields in the select list:
var myOrderHed2 = Db.OrderHed.Where(x=>x.Company == CompanyID && x.OrderNum == myOrderNum).Select(x=>new{x.OrderNum,x.MyUDField_c,xMyUDField2_c}).FirstOrDefault();
1 Like

This was it! The upgrade simply consolidated all of these fields into the UD table. So the UD columns were simply there “in the main table” as facilitated by the UD table. Zero need to query the UDTable anymore.

Thanks everyone!