Hey everyone, struggling to figure out how I do this. I need to capture any changes to the OrderHed, OrderDtl, and OrderRel RequestDate, and insert it to a UD table. The next step for this is displaying a Data Form, that will prompt the user for why they changed it.
It seems like its similar to @jgiese.wci 's BPM that he shows here. https://www.epiusers.help/t/bpmdata-form-error-e10/41226/3?u=chriskrajewski
I have tried some code from this thread also https://www.epiusers.help/t/orderhed-ud-field-bpm/116490?u=chriskrajewski
This allows me to get it sorta working, but with some NullReferenceExceptions when I touch anything related to the Unchanged row.
This is my ugly code if anyone wants to see it. Don’t be too harsh
This sorta works, but with NullRef errors
// Select the OrderRel that has been Updated
var newOrderRel = ds.OrderRel.FirstOrDefault(x => x.Updated());
// If we have an updated row continue
if(newOrderRel == null) return;
var origOrderRel = ds.OrderRel.FirstOrDefault(x => x.Unchanged() && x.SysRowID == newOrderRel.SysRowID && x.ReqDate != newOrderRel.ReqDate).ReqDate;
this.PublishInfoMessage($"New: {newOrderRel.ReqDate} RowMod: {newOrderRel.RowMod} OrigDate: {origOrderRel}", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
if (origOrderRel != null && origOrderRel != newOrderRel.ReqDate )
{
this.PublishInfoMessage($"{origOrderRel}", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}
Once I have the Original, Changed, and eventually Data Form responses, this is what I am using to insert to UD02, and this works.
// Using the UD02Svc -> Add / Update Row
using(var svc = Ice.Assemblies.ServiceRenderer.GetService<UD02SvcContract>(this.Db))
{
var ds = new Ice.Tablesets.UpdExtUD02Tableset();
{
var row = new Ice.Tablesets.UD02Row()
{
Company = callContextClient.CurrentCompany, // Current Company
Key1 = "ShipDate.ReasonCode", // Name of Method Directive Responcible for Managing this Data
Key2 = callContextBpmData.Number01.ToString(), // OrderNum
Key3 = callContextBpmData.Number02.ToString(), // OrderLine
Key4 = callContextBpmData.Number03.ToString(), // OrderRelNum
Key5 = Guid.NewGuid().ToString(),
Date01 = callContextBpmData.Date01, // Orginal ShipDate
Date02 = ttOrderDtl_Row.RequestDate, // New ShipDate
Character01 = callContextBpmData.Character01, // Reason Code Comment
ShortChar01 = callContextClient.CurrentUserId, // UserID
ShortChar02 = callContextClient.CurrentPlant.ToString(), // Current Plant
Date03 = DateTime.Now
};
ds.UD02.Add(row); //'add to dataset'
}
string ErrorMessage = "";
bool errorOccurred = false;
BOUpdErrorTableset boUpdateErrors = svc.UpdateExt(ref ds, true, true, out errorOccurred);
}
If anyone has any working example’s or BPM’s that they could share, or even help with pointing me in the right direction on this, I will be forever in your debt!
Thanks!
Chris