aarong
(Aaron Gulley)
September 13, 2022, 8:41pm
1
Hi All,
Can anyone tell me why this isn’t working?
Erp.Tables.RcvDtl RcvDtl;
foreach (var tt in ttResults.Where(tt => tt.Updated() || tt.Added()))
{
RcvDtl = (from rd in Db.RcvDtl.With(LockHint.UpdLock) where
rd.Company == callContextClient.CurrentCompany &&
rd.PONum == poNum &&
rd.PackSlip == packSlip &&
rd.VendorNum == tt.RcvDtl_VendorNum &&
rd.PurPoint == tt.RcvDtl_PurPoint
select rd).FirstOrDefault();
if(RcvDtl!=null)
{
RcvDtl["SubConProcd_c"] = vProcessed;
Db.Validate();
}
}
It’s currently on a CustomCode block on a UBAQ - GetList Post Processing
cfinley
(Chance Finley)
September 14, 2022, 1:54am
2
I would suggest putting some things in here to debug with. Either in the Ice logs or in a trace How to write your own trace logs - #2 by hmwillett
I’m wondering if your ttResults data is looping over anything with the where criteria. Second gut would be method
aarong
(Aaron Gulley)
September 14, 2022, 8:22am
3
Checked all of that I can’t seem to get it to work with the method…
hkeric.wci
(Haso Keric)
September 14, 2022, 12:08pm
4
Few thins in a GetList POST there will be no Updated or Added records. Just use ttResults.ToList()
and the second I am not sure if callContextClient.CurrentCompany
would be populated, I would recommend using ttResults.Company
1 Like
aarong
(Aaron Gulley)
September 14, 2022, 12:24pm
5
Hi Haso,
Unfortunately, that didn’t work
Not sure why is this a massive problem? I’m struggling with this one
Erp.Tables.RcvDtl RcvDtl;
foreach (var tt in ttResults.ToList())
{
try
{
using (var txscope1 = IceDataContext.CreateDefaultTransactionScope())
{
RcvDtl = (from rd in Db.RcvDtl.With(LockHint.UpdLock) where
rd.Company == "TEAGLE" &&
rd.PONum == poNum &&
rd.PackSlip == packSlip &&
rd.VendorNum == vendorNum &&
rd.PurPoint == purPoint
select rd).FirstOrDefault();
if(RcvDtl!=null)
{
RcvDtl["SubConProcd_c"] = vProcessed;
Db.Validate();
}
}
}
catch (Exception ex)
{
Epicor.Hosting.Trace.ServerLog.WriteNonOperationException(ex);
throw ex;
}
}
Chris_Conn
(Chris Conn)
September 14, 2022, 12:41pm
6
Either use a event log entry or bpm msgbox to sus out the situation.
First how many records do this contain? ttResults.Where(tt => tt.Updated() || tt.Added()))
If that is as expected I’d do the same to determine if RcvDtl is null
Finally, log what vProcessed is per loop
(Also dont forget to look at any RcvDtl data directives that could be interferring)
aarong
(Aaron Gulley)
September 14, 2022, 12:46pm
7
Event logs are telling me absolutely nothing.
Here is the full code snippet, it’s some how skipping the RcvDtl section.
bool brequiresUserInput = false;
string spcMsg = "";
int piMsgType = 0;
string pcPCBinAction = "";
string pcPCBinMessage = "";
decimal pdSerialNoQty = 0;
bool bplNegQtyAction = true;
string pcMessage = "";
string pcPartTranPKs = "";
string pcProcessID = "RcptToInvEntry";
//decimal dLaborQty = (r.RcvDtl_OurQty);
string errorMsg = "";
//string strWarehouseCode = (r.RcvDtl_WareHouseCode);
//string strBinNum = (r.RcvDtl_BinNum);
//string strJobNum = (r.JobOper_JobNum);
int iAsmbSeq = 0;
string tranReference = "UBAQ Auto Receipt for PUR-SUB";
string lotNum = "";
//string strLaborQty = "0";
//int poNum = (r.RcvHead_PONum);
int key1Num = new Random().Next(1000, 9999);
string strCompany = Session.CompanyID;
try
{
using(var jobRcpttoInv = Ice.Assemblies.ServiceRenderer.GetService<ReceiptsFromMfgSvcContract>(Db))
{
ReceiptsFromMfgTableset RcptfrMfgDS = new ReceiptsFromMfgTableset();
jobRcpttoInv.GetNewReceiptsFromMfgJobAsm(jobNum,0,"MFG-STK","RcptToInvEntry",ref RcptfrMfgDS);
//RcptfrMfgDS.Tables["PartTran"].Rows[0]["Company"] = Session.CompanyID;
RcptfrMfgDS.PartTran[0].Company = Session.CompanyID;
RcptfrMfgDS.PartTran[0].WareHouseCode = warehouseCode;
jobRcpttoInv.OnChangeWareHouseCode(pcProcessID, ref RcptfrMfgDS);
RcptfrMfgDS.PartTran[0].ActTranQty = tranQty;
RcptfrMfgDS.PartTran[0].RowMod = "U";
jobRcpttoInv.OnChangeActTranQty(ref RcptfrMfgDS,out spcMsg);
RcptfrMfgDS.PartTran[0].BinNum = binNum;
RcptfrMfgDS.PartTran[0].ActTranQty = tranQty;
jobRcpttoInv.PreUpdate(ref RcptfrMfgDS, out brequiresUserInput);
RcptfrMfgDS.PartTran[0].TranQty = tranQty;
RcptfrMfgDS.PartTran[0].ThisTranQty = tranQty;
RcptfrMfgDS.PartTran[0].TranReference = Convert.ToString(key1Num);
RcptfrMfgDS.PartTran[0].LotNum = "";
jobRcpttoInv.VerifySerialMatchAndPlanContract(ref RcptfrMfgDS,out spcMsg,out piMsgType,out pcPCBinAction,out pcPCBinMessage);
jobRcpttoInv.ReceiveMfgPartToInventory(ref RcptfrMfgDS,pdSerialNoQty,bplNegQtyAction,out pcMessage,out pcPartTranPKs,pcProcessID);
}
}
catch (Exception ex)
{
Ice.Diagnostics.Log.WriteEntry(ex.Message);
}
try
{
using (var txscope1 = IceDataContext.CreateDefaultTransactionScope())
{
var rcvDtl = Db.RcvDtl.Where(p=>
p.Company == strCompany
&& p.VendorNum == vendorNum
&& p.PONum == poNum
&& p.PackSlip == packSlip
&& p.PurPoint == purPoint
&& p.PackLine == packLine
&& p.PartNum == partNum
).FirstOrDefault();
if(rcvDtl != null)
{
rcvDtl.SubConProcd_c = vProcessed;
}
Db.Validate();
txscope1.Complete();
}
}
catch (Exception exDtl)
{
Ice.Diagnostics.Log.WriteEntry(exDtl.Message);
}
using (var txScope = IceContext.CreateDefaultTransactionScope())
{
UD14 newRow = new UD14();
Db.UD14.Insert(newRow);
newRow.Company = Session.CompanyID;
newRow.Key1 = Convert.ToString(key1Num);
newRow.Key2 = Convert.ToString(poNum);
newRow.Key3 = jobNum ;
newRow.Key4 = "";
newRow.Character01 = "AutoReceipt of PO: " + poNum + " Number";
newRow.CheckBox01 = true; // or false
Db.Validate();
txScope.Complete();
}
vProcessed is just a string with the word Processed
and there is currently only one row on the BAQ…
I just had a look into RcvDtl Data Directives and I cannot see any what would be blocking as there isn’t any
Chris_Conn
(Chris Conn)
September 14, 2022, 12:53pm
8
var candidates = Db.RcvDtl.Where(p=>
p.Company == strCompany
&& p.VendorNum == vendorNum
&& p.PONum == poNum
&& p.PackSlip == packSlip
&& p.PurPoint == purPoint
&& p.PackLine == packLine
&& p.PartNum == partNum
);
Ice.Diagnostics.Log.WriteEntry(candidates.Count());
What does that log?
aarong
(Aaron Gulley)
September 14, 2022, 1:20pm
9
It’s resolved now, I had a quick chat with Haso…
I did have a BPM Data Directive set to “Changed Rows” and it was instantly changing it back to “Unprocessed” from “Processed”