I have come to the conclusion that invoking BO Objects especially the ones that do an Update are broken. They yield incorrect results and have been forever. I couldnāt imagine a world without Custom Code you would be dead in the water for any serious customization.
But even more frustrating for the community that Epicor doesnāt mention āBefore Imageā in any of their guides or at Insights for a decade that Iāve been around.
Typical Behaviour when Epicor does an Update
It sends Modified Row with a RowMod āā (blank) and RowMod āUā which allows you to use conditions such as āIf field changed from x to yā among other things.
When you use Widgets Epicor obviously never creates the āBefore Imageā. You can create it just fine when you do Custom Code.
var dsInvoice = bo.GetByID(row.InvoiceNum);
var originalRow = dsInvoice.InvcHead.NewRow();
BufferCopy.Copy(dsInvoice.InvcHead[0], originalRow);
dsInvoice.InvcHead.Add(originalRow);
You could probably do that with nightmarish widgets as well by cluttering your flow with a bunch of nonsense
In addition when Epicor does updates it sends only the tables modified to your PRE, when you do an Update via a Widget you get the entire dataset, which is fine - just keep in mind not to rely on that.
Lastly, Sometimes you need to do an Update in a POST and Epicor doesnāt have a Widget approach to ignoring facades but you can do that just fine in code and avoid the circular loop of death.
When you use Ice.Assemblies.ServiceRenderer.GetService(Db, true) you are also setting the ignoreFacade to trueā¦ What is a Facade in Epicor? Well if you use the ICE SDK and you create your own Business Objects you always create a SvcFacade.cs file which contains the required code for interacting with BPMā¦ So by setting ignoreFacade to true you are basically sayingā¦ Do Not Trigger the āUpdateā BPMā¦ perhaps you want it, but if you are in the Update already you would cause a loop.
Lets not even start with loops
Loops in Widgets are the worst.
Joining ttTable to Db Table
This is considered a crime and should be thought to be avoided at all costs.
Changed Includes Delete
In Epicorās custom code guide they state that Changed = Add/Update but it also include Delete so you are better of using Added or Updated individually instead of Changed. Their Guide is wrong its not just Added or Updated.
Conclusion
Iāve done Custom Code for many years and have been giving Widgets a try lately, only to stumble upon limitations and limitationsā¦ For example RcvMisc.RowMod isnāt accessible via Set Field
but you can set it fine via Custom Code
. That among many other things simply seem not to be getting any love from Epicor.
Stuck in 1735
Also why are we still stuck on C# 6 compilation; canāt even use ValueTuple
What are your favorite widgets gotchas?