Hi Any Expert here to advise me is there something I did wrongly in my code for BPM custom code.
I would like to use BPM code to automatically dispatch my Requisition Send to PO stage but I hit an error as following, I had did many way to change the coding logic but still no luck.
var ReqDataSet = new Erp.Tablesets.ReqTableset();
Erp.Contracts.ReqSvcContract hReq = null;
hReq = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.ReqSvcContract>(Db);
if (hReq != null)
{
ReqDataSet = hReq.GetByID(1234);
hReq.BuildNextDispatcher("PO", out a, out b);
var RHed = (from RH in ReqDataSet.ReqHead where RH.ReqNum == 1234 select RH).SingleOrDefault();
if (RHed != null)
{
RHed.NextActionID = "PO";
RHed.NextActionDesc = "Create Purchase Order";
RHed.ReplyOption = "A";
RHed.ReqUserId = "PRUser";
RHed.RowMod = "U";
hReq.Update(ref ReqDataSet);
hReq.CheckToDo(auth.RequestorID);
hReq.RDMenuFlags(iPR,auth.RequestorID,out c, out d);
hReq.GetReqLogList("ReqNum = '" + sPR + "'", 100, 1, out c);
}
}
as i hit the following error:
Program Ice.Services.Lib.RunTask raised an unexpected exception with the following message: RunTask: BPM runtime caught an unexpected exception of ‘ArgumentNullException’ type.
See more info in the Inner Exception section of Exception Details.
Stack Trace:
at Epicor.Customization.Bpm.DirectiveBase`3.Execute(TParam parameters) in C:_Releases\ICE\ICE3.2.400.0\Source\Server\Internal\Lib\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 162
and also I found this error line as follow:
Inner Exception:
Value cannot be null.
Parameter name: fromItem
Stack Trace:
at Epicor.Data.BufferCompare.Compare[TTypeFrom,TTypeTo](TTypeFrom fromItem, TTypeTo toItem, List1 usingList, List1 exceptForList, List`1 resultsList) in C:_Releases\ICE\ICE3.2.400.0\Source\Shared\Framework\Epicor.ServiceModel\Data\BufferCompare.cs:line 264
at Erp.Services.BO.ReqSvc.ReqHeadBeforeUpdate() in C:_Releases\ERP\UD10.2.400.18\Source\Server\Services\BO\Req\Req.cs:line 2255
at Erp.Services.BO.ReqSvc.OnRowEvent(DataTableEventType type, String tableName, IceRow row) in C:_Releases\ERP\UD10.2.400.18\Source\Server\Services\BO\Req\Req.Designer.cs:line 485
I think just the term of .Any() is not found and need to search which reference should use, the definitely able to work in screen customization but i think is not working in BPM custom code.
I did test few way round by moving the line method up and down, but just does not have idea where the exception throw null value.
Sorry just to add on my error that i think my code does not have any syntax, the error which I attach from first was Run Time Error
I encounter the error come from the line when I try to update my dateset, something been null and unable to update to get through.
I would do it manually, tracing the Update dataset parameters. Then make sure when you do your code you have the same elements in your ReqDataSet set. My guess is one of the fields in your ReqDataSet is null and the BO is expecting a value.
Edit: On second thought, the error seems to stem from ReqHeadBeforeUpdate. So maybe there’s a field missing in a RHead element.
Thanks Doug, and you are correct, is there any place to view the compulsory field or not null for the dataset, i did try on BL-Tester too but I’m still new to no idea how to check which field must not null.
This is my main issue which stuck me quite some time and not able to solve.
First, more context will be needed, is this a method or data directive, what table\method, pre\post\intrans\standard
It looks to me the issue is happening in base code. Are you modifying a record before Epicor is trying to change it?
Regarding the Any(), it’s great. It’s a feature of Linq and Linq is configured by default in BPMs so you are good there. You could potentially start simplifying.
for example, do you still get the error if you comment our everything below RHed != null?
Hi Doug,
I notice that the last line was updating UD_SysRevID but how would this define in code to update the system.byte[] ?
For the rest been filled except the UD_SysRevID.