Customer Field to Copy in OrderHed Field

Hi guys I’m new to Epicor and trying to work on something. I have created a new field (PCC_c) on Customer and OrderHed, I’m having hard time how to make the field from Customer.PCC_c to reflect same on OrderHed.PCC_c

I tried doing it to by Directive Maintenance and I’m kinda lost. I need any guidance from the group. Any help much appreciated. Thank you

My typical way to handle something like that is to create a PreProcessing method directive on Customer.Update that checks whether or not PCC_c changed, and if so, set a flag.
Then in a PostProcessing method directive on Customer.Update, check to see if that flag is set, and if so, go update the order.

Thank you. I tried but how come I can’t find the OrderHed table?

Hi Sam,

Is the idea to update the value from customer on new and existing (open) orders? Or just pull the value from customer when you create a new order?

Nik

Hello Nik, the idea was when I updated a checkbox (PCC) on Customer which its work. I wanted to apply it to all new and existing orders.

I’ve been searching to any answers but till now I can’t get it work.

Okay, this part is for the new orders:
when in order entry, depending in which version of the software you are, either use the tracing option or if Kinetic, the browser built in developer tools to figure out which method is being called when you select a customer on your order header. Once you know that you can add a post process method directive that adds the value from your customer record to your order head record.
For me it looks something like this:


if you click on the method name in developer tools and go to the header section, yo will see which BO and method are being called:

use this information when you go to method directives maintenance.
use the search icon


to open the search dialog, type in the values, first service salesorder, then methodname = ChangeOrderHedCustomerCustID

click search and select the proposed method.
then create a post-process directive where you add a custom code section (C#) and write following code:

// custom code created by Sam (sam@sam.com) [09/26/2025]

foreach(var row in ds.OrderHed.Where(r=>r.RowMod != ""))
{
    int custnum = row.CustNum;
    if(custnum != null)
    {
        var customvalue = Db.Customer.Where(r=>r.Company == Session.CompanyID && r.CustNum == custnum).Select(r=>r.PCC_c).FirstOrDefault();
        if(customvalue != null)
        {
            row.PCC_c = customvalue; 
        }
    }
}


This is what I get

‘OrderHedRow’ does not contain a definition for ‘PCC_c’ and no accessible extension method ‘PCC_c’ accepting a first argument of type ‘OrderHedRow’ could be found (are you missing a using directive or an assembly reference?)

For the other part where you update the customer information and need to pass that to any open order, you need to follow the principle suggested already here by Marjorie, first do a preprocess directive on the customer update where you check in a condition if the PCC_c value has been changed from any to any => enable post process directive. In the post process directive, create a condition that checks if it has been enabled from the correct preprocess directive, on true add a C# custom code widget and add following code:

// custom code created by Sam (sam@sam.com) [09/26/2025]

using (var tx = IceDataContext.CreateDefaultTransactionScope())
{
foreach (var c in ds.Customer.Where(r => r.RowMod == “U”))
{
var comp = c.Company; var cust = c.CustNum;
bool pcc = Convert.ToBoolean(c[“PCC_c”] ?? false);

foreach (var oh in Db.OrderHed.Where(o => o.Company == comp && o.CustNum == cust && o.OpenOrder))
  if (((oh["PCC_c"] as bool?) ?? false) != pcc) oh["PCC_c"] = pcc;

}
Db.Validate();
tx.Complete();
}

Seems I can’t save the first part since I always run into error. How do I resolved the reference error

Sorry about that - I don’t have that field in my database so for me the editor gave an error no matter what :slight_smile: simply use row[“PCC_c”] instead.

1 Like

In the second case, I just want to point out that you are allowed to use this type of code with direct database update only when you are updating your own custom fields, should you use it to update any native Kinetic fields you would risk going around the Business Object logic and might end up with corrupted data in your database, just something to bear in mind.

1 Like