Hello!
I have created a Data Directive BPM on the SysTask to trigger custom code after Generate PO Suggestion status changes to complete.
In the Custom Code I run a LINQ query to analyze the POSuggDtl records and compare the parts within each suggestion to another LINQ PartPlant table query to find parts that have a PONum and POLine(custom UD fields I created).
If there is a matching PartPlant record that has a PONum, and POLine tied to it and the PO is in the system I then access the service contract of PO to create the release from the data loop on the suggestion table.
using(Erp.Contracts.POSvcContract svc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.POSvcContract>(Db))
{
svc.GetNewPORel(ref dsPO, blanketPO, blanketPOLine);
Erp.Tablesets.PORelTable poRel = dsPO.PORel;
svc.ChangeRelOurQty(suggestedQty, ref dsPO,out outStr);
poRel[poRel.Count-1].XRelQty = suggestedQty;
poRel[poRel.Count-1].RelQty = suggestedQty;
poRel[poRel.Count-1].BaseQty = suggestedQty;
poRel[poRel.Count-1].DueDate = DateTime.Now;
poRel[poRel.Count-1].BaseUOM = sugg.PUM;
poRel[poRel.Count-1].PromiseDt = null;
poRel[poRel.Count-1].FromPOSugChg = true;
if(sugg.DueDate!=null)poRel[poRel.Count-1].ReqChgDate = Convert.ToDateTime(sugg.DueDate);
poRel[poRel.Count-1].DueDateChanged = true;
poRel[poRel.Count-1].SetRowState(Ice.IceRowState.Added);
}
After releases have been added I then delete the suggestion removing it from the system. The BPM works great! It adds the releases to the PO and unapproves/re-approves the PO during the process.
However since the suggestions were deleted and that there is a release to satisfy the suggestion the next time the scheduled Generate PO Suggestion runs it re-adds the same suggestions to POSuggDtl table when it shouldn’t since the suggestions should’ve been satisfied.
After looking in Time Phase I noticed none of the programatically added PO releases show up there. I then ran a query and discovered that none of the programatically created releases exists in the PartDtl table either.
If you change a field any field on the PO Release using the UI and hit save the PO release that you changed will then show up in the PartDtl table as well as Time Phase. None of the other programatically added release will show in the PartDtl or Time Phase until you individually update them within the Epicor Client/UI itself.
This leads me to believe there is an issue with the Service PO Contract itself not following the Business Logic. However I opened up the client DLLs and server assemblies in reflector to look for how the system/UI is currently adding the PartDtl records but unfortunately I have had no luck in finding it.
Wondering if anyone else has the same issue and or maybe knows a work around?