I have to add an exception whenever someone tries to add a credit memo to an RMA when there is no RMA Disposition tied to that RMA.
I’m doing a Pre-Process BPM on Erp.RMAProc.RMACreditAdd. I can’t seem to get my code to work. Can anyone take a look and let me know what I’m not doing correctly? I’m not seeing my first infomessage letting me know that I’m in the foreach loop.
//The purpose of this script is to block adding a Credit Memo to an RMA if there is no RMA Disposition.
Erp.Tables.RMADtl RMADtl;
Erp.Tables.RMADisp RMADisp;
//Epicor.Customization.Bpm.InfoMessage.Publish(“FOUND BPM”);
foreach (var ttInvcDtl_iterator in (from ttInvcDtl_Row in ttInvcDtl
where string.Equals(ttInvcDtl_Row.RowMod, IceRow.ROWSTATE_ADDED, StringComparison.OrdinalIgnoreCase)
select ttInvcDtl_Row))
{
var ttInvcDtl_xRow = ttInvcDtl_iterator;
//Epicor.Customization.Bpm.InfoMessage.Publish("ttInvcDtl_xRow.RMANum: " + ttInvcDtl_xRow.RMANum);
if(ttInvcDtl_xRow != null)
{
//Epicor.Customization.Bpm.InfoMessage.Publish("FOUND ttInvcDtl_xRow");
RMADtl = (from RMADtl_Row in Db.RMADtl
where RMADtl_Row.Company == Session.CompanyID
&& RMADtl_Row.RMANum == ttInvcDtl_xRow.RMANum
&& RMADtl_Row.RMALine == ttInvcDtl_xRow.RMALine
select RMADtl_Row).FirstOrDefault();
if (RMADtl != null)
{
//Epicor.Customization.Bpm.InfoMessage.Publish("FOUND RMADtl");
RMADisp = (from RMADisp_Row in Db.RMADisp
where RMADisp_Row.Company == Session.CompanyID
&& RMADisp_Row.RMANum == RMADtl.RMANum
&& RMADisp_Row.RMALine == RMADtl.RMALine
select RMADisp_Row).FirstOrDefault();
if (RMADisp.RMANum == null)
{
throw new Ice.BLException("Credit Request can not be requested until the RMA has been dispositioned. Refer to FAC Service standard 'SV-002 - RMA Process' on Team Friedrich for more information. \n-DC BPM");
}
else
{
Epicor.Customization.Bpm.InfoMessage.Publish("RMADTL_Num = " + RMADtl.RMANum + "\n" + "RMADTL_Line = " + RMADtl.RMALine + "InvcDtl_Num = " + RMADisp.RMANum + "\n" + "InvcDtl_Line = " + RMADisp.RMALine);
}
}
}
}