Function Exceptions

Aaron, didn’t even care to look at the tuples… I just thought epicor was expecting the params like this for some reason… As if a function call needed this.

Much appreciated! :smiley:

1 Like

@utaylor I have two functions, one which loops through Quotes based on a criterion for closing and then loops through the open Tasks. For each open Task it is doing the call to the other function to complete the Task, marks as WON and complete. Here is the statement

this.EfxLib.TASKS.TaskWon(t.Key1, t.TaskSeqNum);

t.Key1 is the QuoteNum I am passing

1 Like

Right on Scott, I am doing something similar with PO lines!

Thanks for your help and idea!

Background, I am running an updatable BAQ with advanced BPM update functionality. I have a BPM on Update.Preprocessing that has custom code widget that loops through each row in the ttResults where row mod = “u” and then calls my function that updates the unir price on the PO line.

Anyone know why when I update one row in my function call works fine in my foreach loop, but the second I try and process two rows I get this message: I can update both of the records individually just fine… @Aaron_Moreng @slitzau @josecgomez @Banderson

Correlation ID: a297fa1b-df36-4cd6-9213-df8c11946b86
Description: This is a duplicate entry of an existing record
Program: Epicor.Ice.dll
Method: UpdateRow
Line Number: 1285
Column Number: 21
Table: PODetail

So this is odd and annoying but I recall recently we had a weird issue where the “BO” cached the last record on a loop basically it doesn’t clean up properly and caused this issue.
The solution (annoyingly enough) is to re-instanciate the BO on each loop.

So instead of making a BO then looping
you loop and inside the loop the first thing you do is instanciate a bo and make your calls.

1 Like

Jose,

I am looping through the ttResults in the baq.

For each result that is updated I then pass its PO Num and PO line to the function and the function updates the unit price on that PO line.

I am not instantiating any business object to make these updates.

Maybe I am misunderstanding something.

Can you show your code? It’s kind of hard to trouble shoot without it.

Are you saying that you are instantiating the BO in the function? And then calling the function every time you loop? If that’s the case, then yes it should work, theoretically.

I will show the code.

Here is the Code for the advanced bpm on the updateable BAQ:

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

int PO = Convert.ToInt32(row.POHeader_PONum);
int POLine = Convert.ToInt32(row.PODetail_POLine);
decimal newdocunitprice = Convert.ToDecimal(row.PODetail_DocUnitCost);

this.InvokeFunction(“UpdatePO”,“UpdateApprovedPO”,PO,POLine,newdocunitprice);

}

Here is the function it is calling:

Have you tried different combinations of rows with the same PO? Different PO? Does it always fail on the second row no matter what?

Never mind, it updates the first row not the second.

It updates the first row, not the second. Doesn’t matter if I am updating the same PO or a combination of different POs.

Are those rows for the same PO? (the reason I ask is because the approval can mess things up)

Yes, I tested two rows that both belong to the same PO.

i have also tested two rows that belong to different POs.

Maybe I should set my tableset to null in my function to start… not sure.

The error is so weird.

IoT I would do differently. As the Active Directory Admin abuse is unusually high this month, I need to earn some extra ad dollars…

Check out Azure IoT. MS has really thought through the process of on-boarding devices, locking them down, allowing you to push updates, collecting data, etc. They even have IoT Edge for more secure (or offline like in a cornfield, etc.) situations. There’s also a podcast called The IoT Show while you’re waiting for the next episode of Ted Lasso.

I have several ideas I’d love to try but haven’t got the bandwidth…

Yeah I have been looking at the Edge. You can install it on a device and then use a container.

the only data sent to microsoft is billing data. Everything else processed locally using the model pushed to it.

1 Like

I found a better exception on the server… I don’t know how an update is trying to insert a duplicate key… I’ll have to figure this out.

Description: BPM runtime caught an unexpected exception of ‘UpdateException’ type.
See more info in the Inner Exception section of Exception Details.
Inner Exception: Violation of PRIMARY KEY constraint ‘PK_PODetail’. Cannot insert duplicate key in object ‘Erp.PODetail’. The duplicate key value is (GFI, 73071, 2).
The statement has been terminated.
Program: EntityFramework.dll
Method: Update
Original Exception Type: UpdateException
Framework Method: SaveChanges
Framework Line Number: 364
Framework Column Number: 17

@Banderson can you expand on this?

“Are those rows for the same PO? (the reason I ask is because the approval can mess things up)”

Cause I do think it is causing an issue, the approval I mean. I originally was thinking, this will be easy I’ll just update the unit price on the PO line… then came the, “can’t update, po is approved,” hurdle.

So for each line I am unapproving, updating price then re-approving. I sense that this is where I am causing the issue, but I am not sure. More testing today.

However, I would like to know what your experience has been unapproving and approving POs.

I don’t remember all the in and outs. I just know that in the application I wrote I ended up making a function for approving and un-approving the PO because it was preventing changes.

1 Like

image

2 Likes