Are data directives triggered when DMT uploads?

Hello all, I have a data directive that acts when a new order line is created to check if the manufactured item being sold doesn’t already exist in stock, and if so, to override Make Direct.

It as a single condition node (IF OrderRel has a new record OR IF OrderRel has an updated record) and the rest is in a short piece of C# code.

MakeUnsetter 0.01.txt (2.2 KB)

It works perfectly if an order is created or changed manually.

However, if an order is entered by DMT nothing happens.

Is it normal for DMT to bypass BPMs?

Many thanks for your input!

Steve Fossey

It is trigger even during DMT, but the OrderRel table is very odd.
Once upon a time (or still), it would create the record, change the record, delete the record and then create it again. Some of those events would be visible in the OrderRel Data Directive and some would not.

However, looking at your code, I see a BIG issue. Setting the Make value in this way will not update your demand tables properly (PartDtl, PartWhse, etc).

I would check the DMT Trace, but you should be able to use the Update Method and set this field using the BO.

And, I would offer that you are using more memory in the BPM attached.
Try making queries more like below. I use Lambda, but you can use query syntax. I’m just showing the smaller queries. Also, this code was not tested…

var tt = (from ttOrderRel_Row in ttOrderRel
                      where   !ttOrderRel_Row.Unchanged() && ttOrderRel_Row.Make
                      select  ttOrderRel_Row).FirstOrDefault();
if (tt != null)
      decimal whQty =   Db.PartWhse.Where(W => W.Company == tt.Company && W.PartNum == tt.PartNum && W.WarehouseCode.Contains(tt.Plant)).Select(W => newQty = W.OnHandQty - (W.SalesAllocatedQty + W.SalesDemandQty + W.ReservedQty + W.AllocatedQty)).Sum();
      bool plantNotMake = Db.PartPlant.Any(L => L.Company == tt.Company && L.PartNum == tt.PartNum && L.Plant == tt.Plant && L.SourceType != "M");
      if(tt.SellingReqQty < whQty || plantNotMake)
          // Use the Business Object instead here
          //tt.Make = false;

Thanks, @Jason_Woods, that’s very helpful. As you can probably tell I’m a bit new to this part of the game. This BPM is actually the first I’ve done, and I haven’t learned Lambda expressions yet.

That being said, it sounds like the first thing I have to do is use the business object instead of changing the value in the dataset. Does that mean I need to use a method directive instead? Or can I call the BO from this context? Anyway, thanks for pointing me in the right direction.

You “Could” use the BO in a Data Directive using code, but in this case I think you will be fighting yourself.
Look at it this way:
On a new Order Line, the Release does not yet exist. When you click “Save”, the system generates the Release for you. You want to change a value on this. If you were to try to run the BO on the OrderRel table, it has not yet written the record and you would be fighting yourself.
If you do this as a Method Directive on SalesOrder.Update (this is called via DMT and MasterUpdate), you can check before the save (Pre-Processing) to see if this is a new record by checking if the OrderDtl is being added. Then, use the Enable Post-Processing.
Lastly, in Post-Processing, check if you were enabled by Pre-Processing, then do you magic (GetByID, change OrderRel.Make if needed, Update). If you use the dataset from the main Method Directive, you won’t even have to refresh your screen. Best of all, you didn’t bypass any Epicor logic!

Also, good job stretching your learning and asking questions. Soon, you will be helping the next guy with these techie questions too!

OK, so I’ve got a method directive working thanks to your suggestion @Jason_Woods . I still have some issues (well, my code does; although with Covid and Quarantine, who doesn’t?) but I’ll bring them to a new thread, because my title refers to Data Directives specifically.