Updating PO Line Price - Null Reference Exception - I know this is vague read details

Hello All,

I have a BPM that updates PO line doc unit price. It works fine when there is one release on the PO, but when there are two releases it throws this error (see below). I have done a trace on updating a line that has one release and two releases and I see no differences in the parameters sent or the datasets returned. Kinda at a loss here. Not sure what it could be… I tried to decompile the PO service, but all I can tell is that the PORel_Foreign_Link() method is called a few different times in the service. I don’t understand exactly what it is doing.

Anyone have any ideas on why this error may be happening or what I can do to make it happy?

Correlation ID: 889a098c-0ddb-48dd-b1d8-76f00a53bc5d
Description: BPM runtime caught an unexpected exception of ‘NullReferenceException’ type.
See more info in the Inner Exception section of Exception Details.
Program: Erp.Services.BO.PO.dll
Method: PORel_Foreign_Link
Line Number: 2926
Column Number: 13
Original Exception Type: NullReferenceException

Sounds like an index issue.
Can you post the details of the BPM? Especially if you have any custom code.

1 Like

Here is the call in the updatable BAQ. I was actually trying to upload this to share with the group and when I went to do it in our training environment I started getting this error.

It is the function called UpdatePOLine:

foreach(var row in (from row2 in ttResults where row2.RowMod == “U” select row2))
{

bool IsApproved = false;
IsApproved = Convert.ToBoolean(row.POHeader_Approve);
int PO = Convert.ToInt32(row.POHeader_PONum);
int POLine = Convert.ToInt32(row.PODetail_POLine);
decimal NewDocUnitPrice = Convert.ToDecimal(row.PODetail_DocUnitCost);

if(IsApproved == true)
{
this.InvokeFunction(“UpdatePOLines”,“UnapprovePO”,PO);
this.InvokeFunction(“UpdatePOLines”,“UpdatePOLine”,PO,POLine,NewDocUnitPrice);
this.InvokeFunction(“UpdatePOLines”,“ApprovePO”,PO);
}
else
{
this.InvokeFunction(“UpdatePOLines”,“UpdatePOLine”,PO,POLine,NewDocUnitPrice);
}

}

This is the code in the base processing for the update method on the updatable baq.

The functions are all widget based. I can upload those and the BAQ if you would like and you can try and import them into your training environment. Like I said I was just about to share this with the group but when I went to test it, I saw that multiple releases caused an error.

Yeah, send it over and I can take a look.
The BAQ looks fine, so this call would be the next thing I would look at:

this.InvokeFunction(“UpdatePOLines”,“UpdatePOLine”,PO,POLine,NewDocUnitPrice);

Just shot you a message, don’t want to upload anything broken here.

1 Like

Based on the ILSpy decompile I did, it is doing something after PODetailUpdate and calling the foreign PO rel link method if the PODetail.MultiRel field is set to true in the data set. I might just try and hack it and set it to false… I am not even updating anything on the release and I don’t think unit price has anything to do with the release so setting MultiRel to false on all of the details might be viable… although it is kinda hacky.

1 Like

The weirder thing is that it still updates the unit price even though the error is thrown…

Well, I got as far as loading it and testing it and it… worked perfectly, lol.
Is it possible you have another BPM that’s conflicting?
Can you post the full error?

Lol no way dude! Haha

Yeah here is the full error:

Server Side Error
Server Side Exception
EpicorServerException
Correlation ID: 889a098c-0ddb-48dd-b1d8-76f00a53bc5d
Description: BPM runtime caught an unexpected exception of ‘NullReferenceException’ type.
See more info in the Inner Exception section of Exception Details.
Program: Erp.Services.BO.PO.dll
Method: PORel_Foreign_Link
Line Number: 2926
Column Number: 13
Original Exception Type: NullReferenceException
Server Trace Stack: at Erp.Services.BO.POSvc.PORel_Foreign_Link() in C:_Releases\ERP\UD10.2.500.8\Source\Server\Services\BO\PO\PO.Designer.cs:line 2926
at Erp.Services.BO.POSvc.refreshPORelData() in C:_Releases\ERP\UD10.2.500.8\Source\Server\Services\BO\PO\PO.cs:line 17934
at Erp.Services.BO.POSvc.refreshPOData(String pcCurComp, Int32 piPONum, Int32 piPOLine, Int32 piPORelNum, String pcCalledFrom) in C:_Releases\ERP\UD10.2.500.8\Source\Server\Services\BO\PO\PO.cs:line 17619
at Erp.Services.BO.POSvc.AfterUpdatePostTrans() in C:_Releases\ERP\UD10.2.500.8\Source\Server\Services\BO\PO\PO.cs:line 1554
at Ice.Services.Trace.TablesetProfilingCollector.DoTablesetEventTrace(String tablesetName, String methodName, Action action) in C:_Releases\ICE\UD10.2.500.8FW\Source\Framework\Epicor.Ice\Services\TablesetProfilingCollector.cs:line 198
at Ice.TablesetBound3.InnerUpdate[TUpdater](IceDataContext dataContext, TFullTableset tableset) in C:\_Releases\ICE\UD10.2.500.8FW\Source\Framework\Epicor.Ice\Services\TablesetBound.cs:line 892 at Erp.Services.BO.POSvc.Update(POTableset& ds) in C:\_Releases\ERP\UD10.2.500.8\Source\Server\Services\BO\PO\PO.Designer.cs:line 4445 at Erp.Services.BO.POSvcFacade.Update(POTableset& ds) in C:\_Releases\ERP\UD10.2.500.8\Source\Server\Services\BO\PO\POSvcFacade.cs:line 5831 at Epicor.Functions.FunctionBase3.CallService[TService](Action1 action) in C:\_Releases\ICE\RL10.2.500.0FW\Source\Server\Internal\Lib\Epicor.Functions.Core\FunctionBase.Plugins.cs:line 54 at EFx.UpdatePOLines.Implementation.UpdatePOLineImpl.RunStep(Int32 workflowStep) at Epicor.Functions.FunctionBase3.Run() in C:_Releases\ICE\RL10.2.500.0FW\Source\Server\Internal\Lib\Epicor.Functions.Core\FunctionBase.cs:line 84
at Epicor.Functions.FunctionBase3.Run(TInput input) in C:\_Releases\ICE\RL10.2.500.0FW\Source\Server\Internal\Lib\Epicor.Functions.Core\FunctionBase.cs:line 69 at EFx.UpdatePOLines.Implementation.UpdatePOLineImpl.AdapterRun(Object[] input) at Epicor.Customization.Bpm.UbaqD8F77790F08247F59A62C333EC3EC537.UpdateBaseDirective_UpdateLinePricing_204DFA99A68E42518237BA81B0041BBD.A001_CustomCodeAction() at Epicor.Customization.Bpm.UbaqD8F77790F08247F59A62C333EC3EC537.UpdateBaseDirective_UpdateLinePricing_204DFA99A68E42518237BA81B0041BBD.ExecuteCore() at Epicor.Customization.Bpm.DirectiveBase3.Execute(TParam parameters) in C:_Releases\ICE\RL10.2.500.0FW\Source\Server\Internal\Lib\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 146

I am doing this in the demo database so I don’t believe there are any conflicting BPMs…

Could it be a bug? :face_with_monocle:

Could I use UpdateExt instead of update?

I doubt it’s a bug, but it could be a different configuration of sorts that’s doing something.

You could try UpdateExt. It’s a lot less restrictive.

1 Like

Yeah… so here comes a big ask… how would I do that? It needs a different dataset fed to it. I am used to calling getbyID to get a dataset and then update it from there throughout the BPM.

Good point about the configurations.

So, I’m pretty unfamiliar with using the widgets; I’m one of those guys that just jumps right into code, lol, but the UpdateExt only needs minimal data as it stubs in the rest for you. So, do it the same way you’re currently doing it, but in the dataset, you only need to pass the changes you’re making (like the unit price).

1 Like

I’ll try and instantiate it using custom code widget and then feed it only the parameters that are changing.

Can’t believe it works for you though.

It’s the “IT Effect”.
You know how everything suddenly starts working when you’re trying to show IT? I call that the “IT Effect”. :slight_smile:

1 Like

I have felt the IT effect many times… just wish it started working right now.

UPDATE EXT IS WORKING :smiley:

1 Like