Importing EDI Orders and RequestDate

,

We import EDI orders for multiple customers.

One of our customers requires the ship date to be transmitted back to them immediately after order import/creation.

Luckily things are pretty simple. One release per line, everything has a set ship date based on the date the order is created, and the type of order, (21 days for a direct to customer, 14 for a store, etc)

I have created a BPM that sets the RequestDate on the Order Header based on the criteria. It is an in-transaction data directive on the order header that, when new records are created, checks customer, order type, and sets the appropriate RequestDate depending on the order type. This appears to be working as intended.

From here I am making some assumptions:

I did not bother making a similar directive for the release level, because, as I understand it, when you create a new line/release, the ship date on the release will default to the ship date on the header. Creating an order and adding releases manually seems to confirm this.

When we import orders VIA EDI, however, the ship date on the header is being set as expected, and the ship dates on the releases are also being set as I would expect. BUT, after that, the ship dates on the releases are being changed to the requested date that the customer is including in the PO. The header is remaining unchanged.

I have scoured our existing BPMs up and down looking for something that would be doing this and I do not think it exists. I am inclined to believe this is baked in Epicor behavior, but I am unfamiliar with the EDI import process to know if there is a setting or something that would tell Epicor to not do the thing I want it to stop doing (changing the ship date on the release)

I am currently working with some Epicor folks to get to the bottom of what is happening and I have some ideas of some secondary BPMs I could make to overcome this but they aren’t exactly clean. I just wanted to float this here to see if anyone had a solid idea of what is happening and if there is a ‘correct’ way to modify the behavior.

@hackaphreaka The header to line to release flow is old school one way to save on data entry. The release dates are the only relevant ones and no system sends them back upstream.

What I use that I borrowed from @hkeric.wci in this thread works on edi and I set the header date after the releases are all done.

This looks hopeful.

Are the BPMs created in these methods intended to be custom code only I am trying to make a BPM using widgets and am hitting a brick wall immediately.

@hackaphreaka Sorry, I don’t know I did them in custom code. I would assume since they were originally made for EDI consultants they may be.

The code should be pretty straight forward. This should get you close.

/* set release dates */

DateTime? reqDate = null;

var DemandHeadRow =
  (from row in Db.DemandHead.With(LockHint.NoLock)
  where
    row.SysRowID == DemandHeadRowid
    && row.EDIOrder == true
    && row.POType == string.Empty
  select row
  ).FirstOrDefault();

if (DemandHeadRow != null)
{
    bool shipStore = false;
    // condition for store or end user
    if (shipStore == false)
    {
       reqDate = DateTime.Today.AddDays(21);
    }
    else
    {
       reqDate =  DateTime.Today.AddDays(14);
    }

    var DemandDetailRows =
      (from dd in Db.DemandDetail.With(LockHint.NoLock)
        where
        dd.Company == DemandHeadRow.Company
        && dd.DemandContractNum == DemandHeadRow.DemandContractNum
        && dd.DemandHeadSeq == DemandHeadRow.DemandHeadSeq
        && dd.Posted == true
        && dd.RejectedByUser == false
        && dd.OrderNum != 0
        && dd.POType == string.Empty
        select dd
      ).ToList();

    foreach (var demandRow in DemandDetailRows)
    {
      var OrderDtlRow =
        (from od in Db.OrderDtl
        where
          od.Company == demandRow.Company
          && od.OrderNum == demandRow.OrderNum
          && od.OrderLine == demandRow.OrderLine
        select od
        ).FirstOrDefault();

      if (OrderDtlRow != null)
      {
        using (var txScope = IceContext.CreateDefaultTransactionScope())
        {
          OrderDtlRow.NeedByDate = reqDate;
          Db.Validate(OrderDtlRow);
          
          
          
          var orderRel =  Db.OrderRel.Where(OrderRel_Row => OrderRel_Row.Company == Session.CompanyID && 
          OrderRel_Row.OrderNum == OrderDtlRow.OrderNum && OrderRel_Row.OrderLine == OrderDtlRow.OrderLine).FirstOrDefault();
          if(orderRel != null)
          {

            orderRel.NeedByDate = reqDate;
          
            Db.Validate();
          }
          
          
          txScope.Complete();
        }
      }
    }
}