UDFields not available in Temporary Tables?

We have added a field to APInvHed called PayrollDate_c. We use it for some validations on the lines when an invoice is for one of the temp agencies we work with. Trying to validate when a line on an AP Invoice is entered for one of these suppliers that the PayrollDate field has been populated. Tried a couple things using the objects available in the Method Directives but ended up having no luck and went with code.

PayrollDate = (from APInvHedRow in Db.APInvHed where APInvHedRow.InvoiceNum == InvNum select APInvHedRow.PayrollDate_c).FirstOrDefault();

works fine. No issues.

PayrollDate = (from APInvHedRow in ttAPInvHed where APInvHedRow.InvoiceNum == InvNum select APInvHedRow.PayrollDate_c).FirstOrDefault();

errors telling me that PayrollDate_c field is not available in ttAPInvHed.

If I want to query it in method, it does:

It just doesn’t exist if I want to pull the data from it. Am I missing something obvious?

When dealing with UD Fields on Temp Tables, you will need to use the UDField extension method.

Try

APInvHedRow.UDField<DateTime?>("PayrollDate_c")

in place of

APInvHedRow.PayrollDate_c

This also works:

(DateTime?)APInvHedRow["PayrollDate_c"]

but I think the other method is preferred.

3 Likes

Thank you very much Andrew. I’ve been messing with this for hours.

You can use that format for non-UD fields as well. Comes in handy if you have to call many different fields in the same method.