I get a syntax error if I use Company.Company in my Where clause, but not if I use Company.Company1. I am getting Company.CountryNum = 0 as an output, even though it should be 8 (USA). Company1 seems strange, since it’s not actually the field name in the table as far as I can see…but I’ve seen it referenced like that before.
I believe Company field is renamed as Company1. Not sure why. But I was able to get this working with a condition widget first
and then custom code widget with this code:
It is hard to tell. Are you using variable vCompCountry created in the BPM or in the custom code?. Am I over-seeing anything? I believe we cannot user variable directly.
I am not sure what the end goal is here but anyway. I noticed you used code so here you are (BPM on Customer.Update.Pre):
// get added or updated customer
var cst = (from cstrows in ttCustomer where (cstrows.RowMod=="U" || cstrows.RowMod=="A") select cstrows).FirstOrDefault();
if (cst!=null)
{
// get company
var cmy = (from cmyrows in Db.Company where (cmyrows.Company1==cst.Company) select cmyrows).FirstOrDefault();
if (cmy.CountryNum!=cst.CountryNum)
{
// your logic here...
}
}
Another thing - when you’re typing the code in Epicor’s code editor, you can use CTRL+SPACE for autocomplete. Handy if you don’t know the exact name of the fields.
This worked! I think using the Company value from the ttCustomer table was the trick. Thank you @Dragos and @itsme for all of your help.
The end goal is to set the International Shipment flag on the Customer and Customer Ship To, so that it can be checked against in APR to print the appropriate documentation (e.g. commercial invoice).