I had a BPM in place that was working fine. I had to add another output variable (at the end of the list) to use in the BPM. When I did this, I deleted the function call in the BPM and inserted it anew setting up all of the links between the local variables and the function output. Now when run the BPM, I get the following:

Log Name: Epicor App Server
Source: IceAppServer
Date: 3/23/2021 10:54:40 AM
Event ID: 0
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Description:
Ice.Common.EpicorServerException: BPM runtime caught an unexpected exception of 'InvalidCastException' type.
See more info in the Inner Exception section of Exception Details. ---> System.InvalidCastException: Specified cast is not valid.
at Epicor.Customization.Bpm.BO918F7B5C18F74BB7A75F5FF9BA442691.ReceiveMfgPartToInventoryPreProcessingDirective_CheckQuantities_68ADDA320B2449ADA978A6CDFA1C14EC.A002_InvokeEpicorFunctionAction()
at Epicor.Customization.Bpm.BO918F7B5C18F74BB7A75F5FF9BA442691.ReceiveMfgPartToInventoryPreProcessingDirective_CheckQuantities_68ADDA320B2449ADA978A6CDFA1C14EC.ExecuteCore()
at Epicor.Customization.Bpm.DirectiveBase`3.Execute(TParam parameters) in C:\_Releases\ICE\ICE3.2.700.0\Source\Server\Internal\Lib\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 146
--- End of inner exception stack trace ---
at Epicor.Customization.Bpm.DirectiveBase`3.Execute(TParam parameters) in C:\_Releases\ICE\ICE3.2.700.0\Source\Server\Internal\Lib\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 162
at Epicor.Customization.Bpm.MethodCustomizationBase2`3.<>c__DisplayClass12_0.<RunDirectives>b__3(MethodDirectiveBase`3 dir) in C:\_Releases\ICE\ICE3.2.700.0\Source\Server\Internal\Lib\Epicor.Customization.Bpm\MethodCustomizationBase2.cs:line 144
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at Epicor.Customization.Bpm.MethodCustomizationBase2`3.RunDirectives(TParam parameters) in C:\_Releases\ICE\ICE3.2.700.0\Source\Server\Internal\Lib\Epicor.Customization.Bpm\MethodCustomizationBase2.cs:line 146
at Epicor.Customization.Bpm.CustomizationBase2`3.Execute(TParam parameters) in C:\_Releases\ICE\ICE3.2.700.0\Source\Server\Internal\Lib\Epicor.Customization.Bpm\CustomizationBase2.cs:line 87
at Epicor.Customization.Bpm.BO918F7B5C18F74BB7A75F5FF9BA442691.ReceiptsFromMfgSvcCustomization.ReceiveMfgPartToInventory(ReceiptsFromMfgTableset& ds, Decimal pdSerialNoQty, Boolean plNegQtyAction, String& pcMessage, String& pcPartTranPKs, String pcProcessID)
at Erp.Services.BO.ReceiptsFromMfgSvcFacade.ReceiveMfgPartToInventory(ReceiptsFromMfgTableset& ds, Decimal pdSerialNoQty, Boolean plNegQtyAction, String& pcMessage, String& pcPartTranPKs, String pcProcessID) in C:\_releases\ERP\ERP10.2.700.0\Source\Server\Services\BO\ReceiptsFromMfg\ReceiptsFromMfgSvcFacade.cs:line 1132
at SyncInvokeReceiveMfgPartToInventory(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.700.12\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.700.12\Source\Framework\Epicor.System\Hosting\OperationBoundInvoker.cs:line 28
When I run the function through Swagger, I get the expected data output. When I look at the BPM “code” on the server the variables do all line up with the datatypes. I even created new variables using the “Create New Variable” in the parameters wizard on the BPM.
I’ve not had this happen before, so I’m at a loss as to what to look at next.