How can I create a BPM (Business Process Management) workflow in Epicor ERP to automatically pull data from Customer UserFields, such as Customer.Character01, and populate the corresponding fields in OrderHed when creating a new sales order?
@Leader254 Welcome searching the site for customer copy order gets you this which has working code. It could probably also be done in widgets,
I did try to implement it with the solutions given in the reply, but unfortunately, I couldn’t get it solved. Here is the code I’m using to fix it.
var ttOrderHed = ds.OrderHed.FirstOrDefault();
if (ttOrderHed != null)
{
string customerID = ttOrderHed.CustNum.ToString();
var customer = (from row in Db.Customer
where row.Company == Session.CompanyID && row.CustNum.ToString() == customerID
select row).FirstOrDefault();
if (customer != null)
{
ttOrderHed["RSM_c"] = customer.Character08;
}
}
I have the user field “RSM” populated when I pull a customer, which is tied to Customer.Character08. However, when I’m entering the order for that particular customer, the user field “RSM,” which is tied to OrderHed.RSM_c, is not getting populated.
You have to get the added/updated row so you don’t have to mess with RowMod - just replace Shortchar01 with what you need. This is SalesOrder.Update.Pre method:
// get added/updated header
var oh = (from ohrow in ttOrderHed where (ohrow.RowMod=="A" || ohrow.RowMod=="U") select ohrow).FirstOrDefault();
if (oh!=null)
{
// get customer
var cst = (from cstrow in Db.Customer where (cstrow.Company==oh.Company && cstrow.CustNum==oh.CustNum) select cstrow).FirstOrDefault();
if (cst!=null)
{
// set field
oh["Shortchar01"] = cst["Shortchar01"];
}
}
Also, this will only work when you add or update the order’s header. You will need something similar with order lines and releases.
That worked, thank you all