Object reference not set to instance of an object (NON-Customized Form)

This happens in our Production environment. Our Demo environment, which is about a month or so old does not present with this issue.

We are having issues when creating a new Pack ID for a specific order. We open the Customer Shipment Entry screen, click on New Pack ID, and then type in the SO# and hit Tab, and then the background methods start to process before throwing this error:

Error Message Text

Application Error

Exception caught in: Epicor.ServiceModel

Error Detail

Message: Object reference not set to an instance of an object.
Program: Epicor.ServiceModel.dll
Method: ShouldRethrowNonRetryableException

Client Stack Trace

at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet dataSets)
at Erp.Proxy.BO.CustShipImpl.BuildShipToCustomerList(Int32 orderNum, String& shipToCustomerList)
at Erp.Adapters.CustShipAdapter.BuildShipToCustomerList(Int32 orderNum, String& shipToCustomerList)

When that error is thrown, the Shipment Entry form has populated the following fields:

  • Ship Date
  • Ship Via
  • Customer
  • Ship To

At this time, I click “OK” to dismiss the error and it pops up a 2nd time. Nothing on the Shipment Entry screen changes after the 1st error is dismissed and the 2nd appears.

My first thought was “Customization Issue”, so I ran it as the Base Form, which did not stop the error. My next thought was “BPM”, so I disabled all Methods that were tied to CustShip and hoped that maybe one of them was going to be the culprit. Unfortunately, that was not the case either.

I ran a Trace and performed the same steps, but nothing stood out in there either.

So now my mind goes to the data, thinking there must be an issue there. So I pulled all of the records for this order from the OrderRel table in both Databases (Production and Demo) and compared the 2 for differences.

I have taken the relevant parts of the results and have them posted here:

OrderNum OrderLine OrderRelNum ShipToNum ScheduleNumber MarkForNum DemandReference ShipToCustNum MFCustNum
150812 1 52 808844583 20230702-2417923 808844583 20230608 7073 7073
150812 1 53 808844583 20230723-2433531 808844583 20230628 7073 7073
150812 1 54 808844583 20230723-2433531 808844583 20230717 7073 7073
150812 1 55 ------ 20230813-2449161 ------ 20230724 7073 7073
150812 1 56 ------ 20230813-2449161 ------ 20230810 7073 7073
150812 1 57 808844583 20230815-2451822 808844583 20230925 7073 7073
150812 1 67 808844583 20230813-2449161 808844583 20230821 7073 7073
150812 2 1 808844583 ------ ------ ------ 0 0
150812 2 2 808844583 20230808-2447125 808844583 20230821 7073 7073
150812 2 3 808844583 20230808-2447125 808844583 20230807 7073 7073
150812 2 4 808844583 20230822-2457151 808844583 20231023 7073 7073
150812 2 5 808844583 20230822-2457151 808844583 20230911 7073 7073
150812 2 6 808844583 20230822-2457151 808844583 20230925 7073 7073

As you can see, there are 2 releases for line 1 that do not have a ShipToNum or a MarkFornum (which usually matches the ShipTo), and line 2 release 1 is missing a Schedule Number, MarkForNum, DemandReference, ShipToCustNum and MFCustNum.

With this being an EDI order, I would think that everything that is missing should be filled out, just like the rest of the lines are. Missing a Schedule Number, Demand Reference, etc., could easily cause problems, but I don’t know if they would cause the problem I am encountering.

Am I barking up the wrong tree? Or do y’all think I am heading in the right direction?

Use oTrans.GetNew() on new tool click.

@DineshYadav001 - I am not sure exactly how that would help in this situation. Can you elaborate a little bit more?

Clear client cache?

I once had a customization in Test that, somehow, caused an error in production for one computer. Like, the error literally could only be from what I was building in Test, as it was an error I had programmed. I had yet to import it into production. Clearing the cache fixed it.

I will admit that I did not initially try that, so I did just do it now. Unfortunately, that did not do the trick. :confused:

Can you compare it to the DemandHeader Detail and Schedule tables? Maybe there is an issue with the original mapping and data?

Now this is interesting, @Doug.C

So I ran this:
SELECT * FROM EpicorERP.Erp.DemandHead WHERE OrderNum = '150812'
and looked at the data…the DemandContractNum is 46 and the ScheduleNumber is 1039222.

I then looked into the DemandSchedule by running this:
SELECT * FROM EpicorERP.Erp.DemandSchedule WHERE ScheduleNumber = '1039222'

I would expect to see a bunch of results returned for DemandContractNum 46, with ShipToNum values matching the customer for that Demand Contract…buuuuuuut, what I see are hundreds of entries for DemandContractNum of 34, which is for a completely different customer.

The ScheduleNumber in DemandHead does NOT match the ScheduleNumber in DemandSchedule.

That can’t be right now, can it?

Keys for DemandHead:
Company, DemandContractNum, DemandHeadSeq

Keys for DemandDetail & DemandSchedule:
Company, DemandContractNum, DemandHeadSeq, DemandDtlSeq

So, you would get your 46 and whatever the DemandHeadSeq is from your first query. You can use those two to get the detail from the other two tables.

When I do that using just the key fields as you described, the data looks fine. With one exclusion: The ScheduleNumber returned on the 1st query (SELECT * FROM EpicorERP.Erp.DemandHead WHERE OrderNum = ‘150812’) is not a schedule number for this order/customer.

Everything related to the ScheduleNumber returned all points to a different Customer and DemandContractNum everywhere else in the system.

I would think there would be some correlation with the ScheduleNumber and DemandContractNumber as well, as the 1st query returns both of those values (granted, they are not both Key fields, but nontheless).

If I run
SELECT * FROM EpicorERP.Erp.DemandSchedule WHERE Company = 'EFGONE' AND DemandContractNum = 46 AND ScheduleNumber = '1039222'
I get no results, even though the first query says that there is an order with those values.

Maybe I am misunderstanding and the ScheduleNumber is completely irrelevant in this situation?

Why do you have a Line with ShipToCustNum being 0?

The same error is coming on my screen when I click new tool and that is on custom sheet so on the new click it focus on base sheet nd base sheet I have invisible from property, So I have used getnew method for create new record and error resolved. Means if its not found the key field form then it is showing error.

I don’t think you can use ScheduleNumber. Try the following (filling in your DemandHedSeq for the ???):

SELECT	DemandContractNum, DemandHeadSeq, ScheduleNumber
FROM	Erp.DemandHead
WHERE	Company = 'EFGONE' And DemandContractNum=46 And DemandHeadSeq=???

SELECT	DemandContractNum, DemandHeadSeq, DemandDtlSeq, ScheduleNumber
FROM	Erp.DemandDetail 
WHERE	Company = 'EFGONE' And DemandContractNum=46 And DemandHeadSeq=???
ORDER	BY 3

SELECT	DemandContractNum, DemandHeadSeq, DemandDtlSeq, ScheduleNumber
FROM	Erp.DemandSchedule
WHERE	Company = 'EFGONE' And DemandContractNum=46 And DemandHeadSeq=???
ORDER	BY 3,4

I did it on one of mine and this is what I get:

DemandContractNum DemandHeadSeq ScheduleNumber
----------------- ------------- ------------------------------
1                 12260         

(1 row affected)

DemandContractNum DemandHeadSeq DemandDtlSeq ScheduleNumber
----------------- ------------- ------------ ------------------------------
1                 12260         1            
1                 12260         2            
1                 12260         3            
1                 12260         4            
1                 12260         5            
1                 12260         6            
1                 12260         7            
1                 12260         8            
1                 12260         9            
1                 12260         10           
1                 12260         11           
1                 12260         12           
1                 12260         13           

(13 rows affected)

DemandContractNum DemandHeadSeq DemandDtlSeq ScheduleNumber
----------------- ------------- ------------ ------------------------------
1                 12260         1            1
1                 12260         2            2
1                 12260         3            3
1                 12260         4            4
1                 12260         5            5
1                 12260         6            6
1                 12260         7            7
1                 12260         8            8
1                 12260         9            9
1                 12260         10           10
1                 12260         11           11
1                 12260         12           12
1                 12260         13           13

(13 rows affected)

As you can see for the same demand (order) the schedule number is not consistent between the tables…

I have no idea why it is 0. That is another reason why I am thinking that this is stemming down to an issue with the data, and that is what is causing the error to populate.