Copied to clipboard

Flag this post as spam?

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


  • Bobby B. 9 posts 25 karma points
    Dec 10, 2018 @ 19:44
    Bobby B.
    0

    Umbraco.TypedContent() is null, though id exists...

    I've scoured the documentation and just can't figure out why this doesn't work. I'm making a system for displaying puppy litters. I can loop through all the litters in the system. A litter has a sire, and I can get the ID of that sire, which is 1413. But If I then try to load it with Umbraco.TypedContent(sireID), it comes back null and I can't display any of its properties. What am I doing wrong? This is in a partial view.

    code

    output

  • bob baty-barr 1180 posts 1294 karma points MVP
    Dec 10, 2018 @ 20:57
    bob baty-barr
    0

    are you sure it is published? try republishing and see if that helps -- or is it in the recycle bin?

  • Bobby B. 9 posts 25 karma points
    Dec 10, 2018 @ 21:11
    Bobby B.
    0

    I'm positive it's all published. I went and made sure of it.

  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    Dec 10, 2018 @ 21:33
    Nik
    0

    Hi Bobby,

    2 questions,

    1) What version of Umbraco are you using?

    2) Are Property Value Converters enabled?

    Thanks,

    Nik

  • Bobby B. 9 posts 25 karma points
    Dec 10, 2018 @ 21:40
    Bobby B.
    1

    Bob Baty-Barr helped me figure it out offline. I wasn't casting the calls using IPublishedContent.

    Here is the correct line for Line 21:

    IPublishedContent sire = litter.GetPropertyValue<IPublishedContent>("sire");
    

    I'm using the new content and media pickers, so it looks like casting the pickers is required.

    I'm using v7.11.0

    I wasn't even looking at the documentation on the pickers, just trying to display content.

    Thanks again Bob for the help!

Please Sign in or register to post replies

Write your reply to:

Draft