Populated with one or more items, node.Value<IEnumerable<IPublishedElement>> works as expected.
Nested Content | Single Document Type | Multiple Item mode
Popuated with one or more items, both node.Value<IPublishedElement> and node.Value<IEnumerable<IPublishedElement>> return Object reference not set to an instance of an object.
Nested Content | Object reference not set to an instance of an object.
I've created the following Nested Content Data Type
When using it on a page, the editor could leave it blank, add one or multiple items.
Using the following line, I always get
Object reference not set to an instance of an object
.Any ideas?
Umbraco 8.5.4
Hi Sean,
can you add a check that the node has a value in "items" property, like this:
Another case is that you need to handle nested content differently when only one item selected :
Thanks,
Alex
Thanks @Alex, adding .HasValue hasn't made any difference.
In this scenario, the property could have 0, 1 or more items selected. With that in mind, I tried the following but was still getting the same error.
I've managed to make some progress with the following tests
Nested Content | Single Document Type | Single item mode
Populated with one item,
node.Value<IPublishedElement>
works as expected.Nested Content | Multiple Document Types | Multiple Item mode
Populated with one or more items,
node.Value<IEnumerable<IPublishedElement>>
works as expected.Nested Content | Single Document Type | Multiple Item mode
Popuated with one or more items, both
node.Value<IPublishedElement>
andnode.Value<IEnumerable<IPublishedElement>>
return Object reference not set to an instance of an object.When not using modelbuilder this can be a pain. It seems that adding a second (dummy) element to your nested content config, fixes this.
is working on a reply...