I am trying to populate a field when I generate a PO from POSugg. There are probably more efficient ways to solve this and we are working on alternate solutions, but now my curiosity has got the best of me and I need to know why I am getting the error. Below is the code in the BPM and below that is the error. I know it has something to do with trying to put a variable where the type is different but not sure how to solve it.
foreach (var pod in Db.PODetail)
{
Ice.Contracts.DynamicQuerySvcContract tQuery =
Ice.Assemblies.ServiceRenderer.GetService<Ice.Contracts.DynamicQuerySvcContract>(Db);
Ice.Tablesets.QueryExecutionTableset dsQueryExecution = new QueryExecutionTableset();
Ice.Tablesets.DynamicQueryTableset dsQuery = tQuery.GetByID(“PartCostStdCost”);
Ice.Tablesets.QueryExecutionTableset dsBAQ = tQuery.GetQueryExecutionParameters(dsQuery);
dsBAQ.ExecutionParameter[0].ParameterID = "PartParam";
dsBAQ.ExecutionParameter[0].ParameterValue = PartNum;
dsBAQ.ExecutionParameter[0].IsEmpty = false;
DataSet results = tQuery.Execute(dsQuery, dsBAQ);
if (results.Tables["Results"].Rows.Count == 0)
{
break;
}
else
{
pod["StdCost_c"] = results.Tables["Results"].Rows[0];
}
}
ERROR:
Server Side Exception
BPM runtime caught an unexpected exception of ‘InvalidCastException’ 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 ‘InvalidCastException’ type.
See more info in the Inner Exception section of Exception Details.
Program: RefEmit_InMemoryManifestModule
Method: lambda_method
Original Exception Type: InvalidCastException
Framework Method: A003_CustomCodeAction
Framework Line Number: 0
Framework Column Number: 0
Framework Source: A003_CustomCodeAction at offset 765 in file:line:column :0:0
Server Trace Stack: at lambda_method(Closure , Object , Object )
at Epicor.Customization.Bpm.BOD1DEE7450B0F4CA4A145CBB494342868.GeneratePostProcessingDirective_StdCostSetter_5195297C0C204640B21AC91768846819.A003_CustomCodeAction()
at Epicor.Customization.Bpm.BOD1DEE7450B0F4CA4A145CBB494342868.GeneratePostProcessingDirective_StdCostSetter_5195297C0C204640B21AC91768846819.ExecuteCore()
at Epicor.Customization.Bpm.DirectiveBase`3.Execute(TParam parameters) in C:_Releases\ICE\ICE3.2.200.33\Source\Server\Internal\Lib\Epicor.Customization.BPM\DirectiveBase.Generic.cs:line 147
Client Stack Trace
at Epicor.ServiceModel.Channels.ImplBase1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets) at Erp.Proxy.BO.POSuggImpl.Generate(POSuggDataSet ds, String ipPlantKey, String ipCurBuyer, Nullable
1 ipCutOffDate)
at Erp.Adapters.POSuggAdapter.Generate(String ipPlantKey, String ipCurBuyer, Nullable`1 ipCutOffDate)
Inner Exception
Specified cast is not valid.