Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • ggesheva 15 posts 115 karma points
    May 11, 2023 @ 05:36
    ggesheva
    0

    Model Builder: Non-Required Fields Expecting Input and Causing Null Reference Exception

    Hi everyone,

    I've recently been working on a project using Umbraco v10.4.2, and I'm having some issues with the model builder. Specifically, I've noticed that some of the fields generated by the model builder are expecting an input even when the field is not marked as required in the back office. This issue is causing the generated .cs model to throw a "System.NullReferenceException: Object reference not set to an instance of an object." error.

    enter image description here

    I found that this error is occurring because the _publishedValueFallback property is staying null for the fields that are not marked as required. This is causing issues when the model is generated and the code tries to access these fields.

    I'm wondering if anyone else has experienced this issue and if there are any workarounds or fixes that can be implemented. I've tried looking through the Umbraco documentation and forum, but I haven't been able to find a solution yet.

  • Frans de Jong 539 posts 1785 karma points MVP 2x c-trib
    19 days ago
    Frans de Jong
    0

    Most of the times weird issues like this are caused by the code calling the property. Can you paste a snipped of the code that refers to this model?

Please Sign in or register to post replies

Write your reply to:

Draft