We are trying to create a bpm that stops the user from processing the Mass Receipt action in the Receipt Entry module if one of the PORels they select has a date in the future.
Originally I was thinking of creating a post process method directive on the update/updateext. Then checking through each row that returns and erroring out an of them that have dates in the future.
I think you are on the right track. Personally I would look into a Pre-Processing directive so that Epicor doesn’t run any of it’s base logic before you back out or throw the error.
@dgreenEA@dgreenEA I do this regular receipt entry preprocessing on GetDtlPOLineInfo. We started off strict and got up to 45 days early during covid. Our official policy is 5 days early, but ehh.
Looking at Mass Receipt I would use preprocessing on PreUpdate to @klincecum’s point get ahead of the update.
foreach (var RcvDtlRowCheck in (from r in ds.RcvDtl where r.Company == Session.CompanyID && r.RowMod == "U" select r))
{
var promdt_CC = Db.PORel.Where(r=> r.Company == callContextClient.CurrentCompany && r.PONum == RcvDtlRowCheck.PONum && r.POLine == RcvDtlRowCheck.POLine && r.PORelNum == RcvDtlRowCheck.PORelNum).Select(r=>r.PromiseDt).DefaultIfEmpty().FirstOrDefault();
var duedt_CC = Db.PORel.Where(r=> r.Company == callContextClient.CurrentCompany && r.PONum == RcvDtlRowCheck.PONum && r.POLine == RcvDtlRowCheck.POLine && r.PORelNum == RcvDtlRowCheck.PORelNum).Select(r=>r.DueDate).DefaultIfEmpty().FirstOrDefault();
var todaydt_CC = DateTime.Now;
DateTime datefix = (DateTime) promdt_CC;
DateTime datefix2 = (DateTime) duedt_CC;
DateTime datefix3 = (DateTime) todaydt_CC;
//int resultdt_CC = DateTime.Compare(promdt_CC, duedt_CC);
if(datefix != null && datefix > datefix3)
{
var lineNum_CC = RcvDtlRowCheck.POLine;
throw new Ice.BLException("The promise date for receipt line " + lineNum_CC + "is set to a future date and cannot be received.");
}
if(datefix == null && datefix2 != null && datefix2 > datefix3)
{
var lineNum_CC = RcvDtlRowCheck.POLine;
throw new Ice.BLException("The due date for receipt line " + lineNum_CC + "is set to a future date and cannot be received.");
}
if(datefix == null && datefix2 == null)
{
var lineNum_CC = RcvDtlRowCheck.POLine;
throw new Ice.BLException("Both dates for receipt line " + lineNum_CC + "are not set.");
}
string body = "ONE ROW HAS BEEN PROCESSED \nPromise Date: " + datefix + "\nDue Date: " + datefix2 + "\nToday Date: " + datefix3;
this.PublishInfoMessage(body, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar","SecondVar");
date1_cc = datefix;
date2_cc = datefix2;
date3_cc = datefix3;
}
Currently, I am unable to get it to throw any of the exceptions in the list. Additionally, I added a message box after the C# block to make sure that it is activating. When the message box block triggers it should show the three date fields at the bottom of the code as I pass those along in scalar variables. Those all come back blank.
Does anyone know what may be causing these errors/message boxes not to show?