KIN-I-5531 - Bubble Up Culprit BPM / Function / Method Directive / Data Directive in Exception
I just spent the better part of 2 hours trying to find a bad data directive, the Only information I had was this exception in system agent.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> Ice.Common.RecordNotFoundException: Record not found.
at Epicor.Customization.Bpm.DirectiveBase`2.ProcessRememberedExceptions() in C:\_releases\ICE\ICE4.2.300.9\Source\Server\Internal\Lib\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 293
at Epicor.Customization.Bpm.DirectiveBase`2.Execute(TParam parameters) in C:\_releases\ICE\ICE4.2.300.9\Source\Server\Internal\Lib\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 222
at Epicor.Customization.Bpm.TriggerBase`2.RunDirectives(TriggerParameters`1 parameters) in C:\_releases\ICE\ICE4.2.300.9\Source\Server\Internal\Lib\Epicor.Customization.Bpm\TriggerBase.cs:line 51
at Epicor.Customization.Bpm.CustomizationBase2`2.Execute(TParam parameters) in C:\_releases\ICE\ICE4.2.300.9\Source\Server\Internal\Lib\Epicor.Customization.Bpm\CustomizationBase2.cs:line 98
at Epicor.Customization.Bpm.InTranTriggerBase2`2.Delete(LinqRow oldRecord) in C:\_releases\ICE\ICE4.2.300.9\Source\Server\Internal\Lib\Epicor.Customization.Bpm\InTranTriggerBase2.cs:line 73
at Ice.Triggers.TriggerQueue.ExecuteBpmDeleteTrigger(IceDataContext context, LinqRow originalRecord) in C:\_releases\ICE\ICE4.2.300.9\Source\Server\Framework\Epicor.System\Triggers\TriggerQueue.cs:line 363
at Ice.Triggers.TriggerQueue.RunDeleteTrigger(IceDataContext context, LinqRow linqRow) in C:\_releases\ICE\ICE4.2.300.9\Source\Server\Framework\Epicor.System\Triggers\TriggerQueue.cs:line 131
at Ice.IceDataContext.DeleteObject(Object entity) in C:\_releases\ICE\ICE4.2.300.9\Source\Server\Framework\Epicor.System\Data\IceDataContext.cs:line 223
at Erp.Internal.PE.Bank_ReconciliationPost_Post.UpdateRelatedTables(String ABTUID) in C:\_releases\ERP\ERP11.2.300.0\Source\Server\Internal\PE\Bank_Reconciliation\Bank_ReconciliationPost_Post.cs:line 246
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at Erp.Internal.PE.ReviewJournal.__ConfirmRJ(Int32 iRvJrnUID, Int32 iACTTypeUID, String iABTUID, Boolean lBankRecFakeUpdate) in C:\_releases\ERP\ERP11.2.300.0\Source\Server\Internal\PE\ReviewJournal\ReviewJournal.cs:line 3244
Now from looking at the stack trace i can clearly see the issue came from a BPM, Specifically an InTranTrigger (Data Directive) but nowhere in that stack is information about which table, method, BO or source.
It required me to hook up a .NET Debugger so I could step through the exception to then find out that it came from a poorly written GetByID in ApChkGrp Data Directive which assumed youâd always have a valid PMUID.
The issue at hand here is that the stack trace provided by .NET doesnât tell us where to look and it can be incredibly time consuming to troubleshoot. If we pass the name and or locatoin (Table, BO, Method) of the Directive into DirectiveBase and then use standard Try Catch Throw you can append to the stack / message the location of said bad directive and save me hours⌠and hair on my head~