BPM runtime caught an unexpected exception of 'ArgumentOutOfRangeException' type

,

Hi,
I have some custom code on an updateable BPM and am getting the error below. I can’t find any hint in it that would point me to where in my code the problem is. My code is below the error.

Server Side Exception

BPM runtime caught an unexpected exception of 'ArgumentOutOfRangeException' type.
See more info in the Inner Exception section of Exception Details.

Exception caught in: Epicor.ServiceModel

Error Detail 
============
Description:  BPM runtime caught an unexpected exception of 'ArgumentOutOfRangeException' type.
See more info in the Inner Exception section of Exception Details.
Program:  CommonLanguageRuntimeLibrary
Method:  ThrowArgumentOutOfRangeException
Original Exception Type:  ArgumentOutOfRangeException
Framework Method:  A001_CustomCodeAction
Framework Line Number:  0
Framework Column Number:  0
Framework Source:  A001_CustomCodeAction at offset 280 in file:line:column <filename unknown>:0:0

Server Trace Stack:     at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at Epicor.Customization.Bpm.Ubaq352D22F5556F447D881FF1D68B74470B.UpdateBaseDirective_CreateCheckHeads_64E00981BA7F474AABD188A8D739AFC5.A001_CustomCodeAction()
   at Epicor.Customization.Bpm.Ubaq352D22F5556F447D881FF1D68B74470B.UpdateBaseDirective_CreateCheckHeads_64E00981BA7F474AABD188A8D739AFC5.ExecuteCore()
   at Epicor.Customization.Bpm.DirectiveBase`3.Execute(TParam parameters) in C:\_Releases\ICE\ICE3.2.100.9\Source\Server\Internal\Lib\Epicor.Customization.BPM\DirectiveBase.Generic.cs:line 131



Client Stack Trace 
==================
   at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets)
   at Ice.Proxy.BO.DynamicQueryImpl.Update(DynamicQueryDataSet queryDS, DataSet queryResultDataset)
   at Ice.Adapters.DynamicQueryAdapter.<>c__DisplayClass27_0.<Update>b__0(DataSet datasetToSend)
   at Ice.Adapters.DynamicQueryAdapter.ProcessUbaqMethod(String methodName, DataSet updatedDS, Func`2 methodExecutor, Boolean refreshQueryResultsDataset)
   at Ice.Adapters.DynamicQueryAdapter.Update(DynamicQueryDataSet queryDS, DataSet updatedDS, Boolean refreshQueryResultsDataset)
   at Ice.UI.App.BAQDesignerEntry.BAQTransaction.<CallUpdate>b__380_0(Int32& rowReturned)
   at Ice.UI.App.BAQDesignerEntry.Forms.BAQDiagramForm.ShowQueryResults(DataSet dsResults, getQueryResult getResults, ReportAdditionalInfo additionalInfo)
   at Ice.UI.App.BAQDesignerEntry.BAQTransaction.CallUpdate()

Inner Exception 
===============
Specified argument was out of the range of valid values.
Parameter name: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
var newInvoice = ttResults;

foreach(var invoice in newInvoice)
 
     {
      using(var invoiceSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.PaymentEntrySvcContract>(this.Db))
        //Trace: <businessObject>Erp.Proxy.BO.PaymentEntryImpl</businessObject>
        
      {
        Erp.Tablesets.PaymentEntryTableset invoiceData = new Erp.Tablesets.PaymentEntryTableset();
        
        invoiceData.CheckHed[0].CheckNum = invoice.Calculated_Check;
        
        //checkData.CheckHed[0].CurrencyCode = 'BASE' 
              
        invoiceSvc.GetNewAPTran(ref invoiceData,0, 0,invoice.Calculated_InvoiceNumber);
        
        var requiredboolean = false;
        invoiceSvc.PostAllowed(invoice.Calculated_Group, out requiredboolean);
        
        invoiceSvc.GetElecInterface(invoice.Calculated_Group, out requiredboolean);
        
        string outstring;
        
        invoiceSvc.OnChangeInvoiceNum(invoice.Calculated_InvoiceNumber,"", ref invoiceData, out outstring);
        
        invoiceSvc.Update(ref invoiceData);
      
        }
            }
              

Assuming you have access to the server what I normally do is use WriteEntry then use the Event Viewer on the server to narrow down the line that is throwing the error. You can add data also, but if the field is null you can also get a error on the WriteEntry, so you have to be careful.

Ice.Diagnostics.Log.WriteEntry($" Before GetElecInterface invoice is {Calculated_InvoiceNumber} ");

I don’t know if this is all of the code, but GetNewAPtrans needs the Check HeadNum that would have been generated on CreateNewCheckHed

That’s a number generated by Epicor and I don’t know how to reference it in my code. I have the checks already in the system, just trying to add invoices to them.

I tried changing it to the codes below and am still getting the error with both

invoiceSvc.GetNewAPTran(ref invoiceData,invoiceData.CheckHed[0].HeadNum, 0,"");

and

invoiceSvc.GetNewAPTran(ref invoiceData,invoiceData.CheckHed[0].HeadNum, 0,invoice.Calculated_InvoiceNumber);

Trace results:

<parameter name="ds" type="Erp.BO.PaymentEntryDataSet">
      <PaymentEntryDataSet xmlns="http://www.epicor.com/Ice/300/BO/PaymentEntry/PaymentEntry" />
    </parameter>
    <parameter name="headNum" type="System.Int32"><![CDATA[115350]]></parameter>
    <parameter name="apTranNo" type="System.Int32"><![CDATA[0]]></parameter>
    <parameter name="invoiceNum" type="System.String"><![CDATA[]]></parameter>

I think @hkeric.wci is on the right track in your other thread. I think Payment Confirmation import is the process you need and appears to not need custom code.

1 Like

The issue with that is the confirmation process matches against payments you’ve set up and sent to the bank. We don’t do that because it won’t let you create a payment without a check number. The bank makes the payment and sends us a list of check numbers it sent. Then we have to enter the checks and match them against the invoices manually.

I am trying to pull the HeadNumber from Epicor using the check number I have. I am getting an error about it not being able to convert ant into a bool but checknum, Calculated_Check and HeadNum are all integers and I don’t know where the bool is coming from…

 int headNum = (from hn in Db.CheckHed where hn.CheckNum = invoice.Calculated_Check select hn.HeadNum.)  FirstOrDefault();
int headNum = (from hn in Db.CheckHed where hn.CheckNum = invoice.Calculated_Check select hn.HeadNum.)  FirstOrDefault();

Should read:

int headNum = (from hn in Db.CheckHed where hn.CheckNum == invoice.Calculated_Check select hn.HeadNum.).FirstOrDefault();

Thanks that worked!!!

My code will now add an invoice thorough my updateable BAQ!! But then I get the error below. I don’t see a method called APTranAfterGetNew available anywhere.

Business Layer Exception

Group record not found.  Update not allowed on posted Groups.

Exception caught in: Epicor.ServiceModel

Error Detail 
============
Description:  Group record not found.  Update not allowed on posted Groups.
Program:  Erp.Services.BO.PaymentEntry.dll
Method:  APTranAfterGetNew
Line Number:  1073
Column Number:  17
Table:  ApTran
Field:  GroupID
Server Trace Stack:     at Erp.Services.BO.PaymentEntrySvc.APTranAfterGetNew() in C:\_Releases\ERP\UD10.2.100.9\Source\Server\Services\BO\PaymentEntry\PaymentEntry.cs:line 1073
   at Ice.Services.Trace.TablesetProfilingCollector.DoRowEventTrace(String tableName, String methodName, Int32 rowCount, Action action) in C:\_Releases\ICE\ICE3.2.100.9\Source\Framework\Epicor.Ice\Services\TablesetProfilingCollector.cs:line 146
   at Ice.TablesetBound`3.InnerGetNew[TDataTable,TDataRow](TDataTable dataTable, Action`1 setForeignKeys) in C:\_Releases\ICE\ICE3.2.100.9\Source\Framework\Epicor.Ice\Services\TablesetBound.cs:line 388
   at Erp.Services.BO.PaymentEntrySvc.GetNewAPTran(PaymentEntryTableset& ds, Int32 headNum, Int32 apTranNo, String invoiceNum) in C:\_Releases\ERP\UD10.2.100.9\Source\Server\Services\BO\PaymentEntry\PaymentEntry.Designer.cs:line 1533
   at Erp.Services.BO.PaymentEntrySvcFacade.GetNewAPTran(PaymentEntryTableset& ds, Int32 headNum, Int32 apTranNo, String invoiceNum) in C:\_Releases\ERP\UD10.2.100.9\Source\Server\Services\BO\PaymentEntry\PaymentEntrySvcFacade.cs:line 2640
   at Epicor.Customization.Bpm.Ubaq1912D2CBED3E44B69B5EFC00D7A6CE80.UpdateBaseDirective_CreateCheckHeads_64E00981BA7F474AABD188A8D739AFC5.A001_CustomCodeAction()
   at Epicor.Customization.Bpm.Ubaq1912D2CBED3E44B69B5EFC00D7A6CE80.UpdateBaseDirective_CreateCheckHeads_64E00981BA7F474AABD188A8D739AFC5.ExecuteCore()
   at Epicor.Customization.Bpm.DirectiveBase`3.Execute(TParam parameters) in C:\_Releases\ICE\ICE3.2.100.9\Source\Server\Internal\Lib\Epicor.Customization.BPM\DirectiveBase.Generic.cs:line 131
   at Epicor.Customization.Bpm.MethodCustomizationBase2`3.RunDirectives(TParam parameters) in C:\_Releases\ICE\ICE3.2.100.9\Source\Server\Internal\Lib\Epicor.Customization.BPM\MethodCustomizationBase2.cs:line 170
   at Epicor.Customization.Bpm.CustomizationBase2`3.Execute(TParam parameters) in C:\_Releases\ICE\ICE3.2.100.9\Source\Server\Internal\Lib\Epicor.Customization.BPM\CustomizationBase2.cs:line 71
   at Epicor.Customization.Bpm.Ubaq1912D2CBED3E44B69B5EFC00D7A6CE80.CHS_PaymentEntry_3SvcCustomization.Update(DynamicQueryTableset queryDS, DataSet& queryResultDataset)
   at Ice.Services.BO.DynamicQuery.Internal.Ubaq.UbaqBpmCaller.Update(DynamicQueryTableset queryDesign, DataSet& queryResultDataset) in C:\_Releases\ICE\ICE3.2.100.9\Source\Server\Services\BO\DynamicQuery\Internal\Ubaq\UbaqBpmCaller.cs:line 101
   at Ice.Services.BO.DynamicQuerySvc.Update(DynamicQueryTableset queryDS, DataSet queryResultDataset) in C:\_Releases\ICE\ICE3.2.100.9\Source\Server\Services\BO\DynamicQuery\DynamicQuery.cs:line 597
   at Ice.Services.BO.DynamicQuerySvcFacade.Update(DynamicQueryTableset queryDS, DataSet queryResultDataset) in C:\_Releases\ICE\ICE3.2.100.9\Source\Server\Services\BO\DynamicQuery\DynamicQuerySvcFacade.cs:line 760
   at SyncInvokeUpdate(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
   at Epicor.Hosting.OperationBoundInvoker.InnerInvoke(Object instance, Func`2 func) in C:\_Releases\ICE\ICE3.2.100.9\Source\Framework\Epicor.System\Hosting\OperationBoundInvoker.cs:line 59
   at Epicor.Hosting.OperationBoundInvoker.Invoke(Object instance, Func`2 func) in C:\_Releases\ICE\ICE3.2.100.9\Source\Framework\Epicor.System\Hosting\OperationBoundInvoker.cs:line 28
   at Epicor.Hosting.Wcf.EpiOperationInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) in C:\_Releases\ICE\ICE3.2.100.9\Source\Framework\Epicor.System\Hosting\Wcf\EpiOperationInvoker.cs:line 23
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
   at System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext request, Boolean cleanThread, OperationContext currentOperationContext)
   at System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext)
   at System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result)
   at System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult result)
   at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
   at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
   at System.ServiceModel.Channels.SecurityChannelListener`1.ReceiveItemAndVerifySecurityAsyncResult`2.InnerTryReceiveCompletedCallback(IAsyncResult result)
   at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
   at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
   at System.ServiceModel.Channels.TransportDuplexSessionChannel.TryReceiveAsyncResult.OnReceive(IAsyncResult result)
   at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
   at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
   at System.ServiceModel.Channels.SynchronizedMessageSource.ReceiveAsyncResult.OnReceiveComplete(Object state)
   at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state)
   at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
   at System.Net.Security.NegotiateStream.ProcessFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.NegotiateStream.ReadCallback(AsyncProtocolRequest asyncRequest)
   at System.Net.AsyncProtocolRequest.CompleteRequest(Int32 result)
   at System.Net.FixedSizeReader.CheckCompletionBeforeNextRead(Int32 bytes)
   at System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult)
   at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
   at System.ServiceModel.Channels.ConnectionStream.IOAsyncResult.OnAsyncIOComplete(Object state)
   at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs e)
   at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)
   at System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)



Client Stack Trace 
==================
   at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets)
   at Ice.Proxy.BO.DynamicQueryImpl.Update(DynamicQueryDataSet queryDS, DataSet queryResultDataset)
   at Ice.Adapters.DynamicQueryAdapter.<>c__DisplayClass27_0.<Update>b__0(DataSet datasetToSend)
   at Ice.Adapters.DynamicQueryAdapter.ProcessUbaqMethod(String methodName, DataSet updatedDS, Func`2 methodExecutor, Boolean refreshQueryResultsDataset)
   at Ice.Adapters.DynamicQueryAdapter.Update(DynamicQueryDataSet queryDS, DataSet updatedDS, Boolean refreshQueryResultsDataset)
   at Ice.UI.App.BAQDesignerEntry.BAQTransaction.<CallUpdate>b__380_0(Int32& rowReturned)
   at Ice.UI.App.BAQDesignerEntry.Forms.BAQDiagramForm.ShowQueryResults(DataSet dsResults, getQueryResult getResults, ReportAdditionalInfo additionalInfo)
   at Ice.UI.App.BAQDesignerEntry.BAQTransaction.CallUpdate()