Hello,
I am looking to complete a BPM that will show an InfoMessage when a user pulls Sales Order Line/Rel into a PackNum in Customer Shipment Entry. The InfoMessage should show when the corresponding Order/Line/Rel ReqDate is in the past (less than today’s date). The InfoMessage is strictly informational and will not stop processing.
I have pieced together a Post BPM on Erp.CustShip.GetOrderRelInfo.
This mostly works, outside of one condition.
In my testing I have three line/releases on an order with ReqDate:
- Earlier than Today - Works
- Later than Today - Works
- Equal to Today - Does Not Work
The only way I could figure out what I’m looking for was to key in on OrderRel_Row.ReqDate < DateTime.Now
I know the DateTIme.Now format will take into consideration the time of day not just the date itself. This is why my message fires for a release with a ReqDate of today (which I’m trying to make not happen).
So my question is two fold.
- Is this BPM a viable way to handle this?
- What can I change in the Custom Code to handle when the date is today?
Any help is much appreciated.
Thanks,
Joe
DateTime vShipTimeNow;
string vRelReqDate;
int vOrderNum = 0;
int vOrderLine = 0;
int vOrderRelNum = 0;
string newDate1;
Erp.Tables.OrderRel OrderRel;
var tempShipDtlRow = (from ttrow in ttShipDtl
where ttrow.Company == Session.CompanyID
select ttrow).FirstOrDefault();
if (tempShipDtlRow != null)
{
vOrderNum = tempShipDtlRow.OrderNum;
vOrderLine = tempShipDtlRow.OrderLine;
vOrderRelNum = tempShipDtlRow.OrderRelNum;
vShipTimeNow = DateTime.Now.Date;
newDate1 = String.Format("{0:d}", vShipTimeNow).ToString();
//this.PublishInfoMessage("Today: " + newDate1, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "Application Name", "Comments");
}
foreach (var OrderRel_Recs in (from OrderRel_Row in Db.OrderRel
where OrderRel_Row.Company == Session.CompanyID
&& OrderRel_Row.OrderNum == vOrderNum
&& OrderRel_Row.OrderLine == vOrderLine
&& OrderRel_Row.OrderRelNum == vOrderRelNum
&& OrderRel_Row.ReqDate < DateTime.Now
select OrderRel_Row))
{
var OrderRel_Row = OrderRel_Recs;
{
vRelReqDate = OrderRel_Row.ReqDate.ToString();
string newDate2 = String.Format("{0:d}", OrderRel_Row.ReqDate);
this.PublishInfoMessage("Order/Line/Release: " + vOrderNum.ToString() + " / " + vOrderLine.ToString() + " / " + vOrderRelNum.ToString() + "\r" + "Is Shipping Late"+ "\r" + "Order Release ShipDate: " + newDate2, Ice.Common.BusinessObjectMessageType.Warning, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}
}