Nop 4.10 - Issue is occurring with one page checkout (Nullable object must have a value

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
"Nullable object must have a value." Error in alert box

Url: /onepagecheckout

How to reproduce:

1. when goes to checkout page as it is onepagecheckout page it have different tabs of
    Billing-address, shipping-address
    https://prnt.sc/krnrdm

2. Now entering the new Billing-address
      https://prntscr.com/krnrzn

3. After complete the Billing-address go to next tab
     https://prntscr.com/krnsbi

4. Go back so it again redirects to the Billing-address tab now try to continue there it gives the    
      error in alert with message as " Null-able object must have value"
      https://prntscr.com/krnta8


Can anyone help me on this

Thanks
5 years ago
Yes seems to be a bit of a bug there
Add a new address then goto next step,
Then click back.
Something happens with Address 2: needs a value or otherwise gives the error above
5 years ago
Any update on this?
5 years ago
In my case problem was with province. I have disable it, but there was checked this field is 'required".  

I fix it in this way:

Go here:
https://.../Admin/Setting/CustomerUser

And now check all field in customer / shipping addres. Try enable all for a moment (without saving), and check do you have something disabled but required. If yes, uncheck it, and disable again not needed in your shop.

In my situation it's fix this problem.

But it's a bug in nopcommerce, to not ignore disabled field.
5 years ago
In my case if i have a required address field, throw exception in AddressService -> "FindAddress" method . Any ideas ?
5 years ago
can you please put error log here that come into Log table?
so we can able to check that where is issue

Go to website.com/Admin/Log/List url for error log
4 years ago
sangeetshah wrote:
can you please put error log here that come into Log table?
so we can able to check that where is issue

Go to website.com/Admin/Log/List url for error log


Log level  
Warning
Short message  
Nullable object must have a value.
Full message  
System.InvalidOperationException: Nullable object must have a value.
   at System.Nullable`1.get_Value()
   at Nop.Services.Common.AddressService.<>c__DisplayClass15_0.<FindAddress>b__0(Address a) in  Libraries\Nop.Services\Common\AddressService.cs:line 279
   at System.Collections.Generic.List`1.Find(Predicate`1 match)
   at Nop.Services.Common.AddressService.FindAddress(List`1 source, String firstName, String lastName, String phoneNumber, String email, String faxNumber, String company, String address1, String address2, String city, String county, Nullable`1 stateProvinceId, String zipPostalCode, Nullable`1 countryId, String customAttributes) in  Libraries\Nop.Services\Common\AddressService.cs:line 279
   at Nop.Web.Controllers.CheckoutController.OpcSaveBilling(CheckoutBillingAddressModel model) in  Presentation\Nop.Web\Controllers\CheckoutController.cs:line 1208

Page URL  
http://localhost:55390/checkout/OpcSaveBilling/
Referrer URL  
http://localhost:55390/onepagecheckout


steps:
1. Fill your information in checkout page.
2. Next until payment
4. Return to previous step billing from  back button
5. Choose new address
6. select country other than US
7. fill address and next (it will work for first time)
8. goto step 4 and hit next it will fail
Alert: Nullable object must have a value.
Note: if you change the name it will work but if you repeat the process again it fails
4 years ago
While debugging, I found that there was null check issue with Country and stateProvinceId
in FindAddress method Libraries\Nop.Services\Common\AddressService.cs
I changed code as following and it started working

Line # 289: ((a.StateProvinceId == null && (stateProvinceId == null || stateProvinceId == 0)) || (a.StateProvinceId != null && a.StateProvinceId == stateProvinceId)) &&

Line # 291: ((a.CountryId == null && countryId == null) || (a.CountryId !=null && a.CountryId == countryId))
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.