Okay, editing because I realize that was a poorly worded question. If this was StackOverFlow you’d all be beating on me now.
I started with a question about data directives here: Are data directives triggered when DMT uploads? which resulted obliquely in me shifting to a method directive thanks to input fro @Jason_Woods . Big stuff for a new guy.
I now have code that does what I need on all manually-entered orders. It also works on a DMT order using “Sales Order Combined”, but the subsequent orders return “transaction aborted”.
Strangely, they do create their orders, but the evaluation step I coded does not occur.
To be clear, my question is:
Can I insert a debugging message that will return a message to the DMT error file and console, into the various steps of my code?
The code I’m using, which works manually, is below; comments on it are welcome too.
//MakeSetter 0.04 May 6, 2020 - Steve Fossey
using (var txScope = IceContext.CreateDefaultTransactionScope())
{
var odtl = (from d in ttOrderDtl select d).FirstOrDefault();
var orl = (from r in Db.OrderRel
where odtl.Company == r.Company &&
odtl.OrderNum == r.OrderNum &&
odtl.OrderLine == r.OrderLine &&
r.Make
select r).FirstOrDefault();
if (orl != null)
{
var ppl = (from pp in Db.PartPlant
where orl.Company == pp.Company &&
orl.PartNum == pp.PartNum &&
orl.Plant == pp.Plant &&
pp.SourceType.Equals("M")
select pp).FirstOrDefault();
if (ppl != null)
{
foreach (var RelRow in (from r in Db.OrderRel.With(LockHint.UpdLock)
where orl.Company == r.Company &&
orl.OrderNum == r.OrderNum &&
orl.OrderLine == r.OrderLine &&
orl.OrderRelNum == r.OrderRelNum &&
orl.PartNum == r.PartNum &&
orl.Plant == r.Plant &&
r.Make
select r))
{
var pw = (from w in Db.PartWhse
where orl.Company == w.Company &&
orl.PartNum == w.PartNum &&
w.WarehouseCode.Contains(orl.Plant)
select w).FirstOrDefault();
if (orl.SellingReqQty <
( pw.OnHandQty -
( pw.SalesAllocatedQty +
pw.SalesDemandQty +
pw.ReservedQty +
pw.AllocatedQty)))
{
try
{
orl.Make = false;
Db.Validate();
txScope.Complete();
}
catch (Exception e)
{
this.PublishInfoMessage("parts on hand debug triggered with exception " + e, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
txScope.Complete();
}
}
}
}
}
}
I also just learned how to format code in this forum, which works better than the code editor in Epicor