Copied to clipboard

Flag this post as spam?

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


  • ReneRam 5 posts 45 karma points
    25 days ago
    ReneRam
    0

    Hi to All. I'm struggling trying to build a query that filters Content by the value of a Property in a Document Type. I need to filter all the items tha have a value selected in a dropdown:

    These are the values that can be selected

    I have tried searching the Forum and in Google, but it looks like I can't Use the GetPropertyValue in Umbraco 8.16.0.

    I'm stuck with this:

    var content = Umbraco.ContentAtRoot().ToList();
    
    var comunicazioni = Umbraco.Content(Guid.Parse(content.First(x => x.Name == "Comunicazioni").Key.ToString()))
    .ChildrenOfType("articoloComunicazioni")
    .Where(x => x.IsVisible())
    .Where(x => x.GetProperty("tipoComunicazione").ToString() == "NEWS")
    .OrderByDescending(x => x.UpdateDate);
    

    Thanks in advance for any help.

  • Biagio Paruolo 1502 posts 1643 karma points c-trib
    25 days ago
    Biagio Paruolo
    0

    You have to Get the value of the stop down. In the Umbraco v8, you cannot read the dropdown value as a string field.

    https://our.umbraco.com/documentation/Fundamentals/Backoffice/Property-Editors/Built-in-Property-Editors/DropDown/

    Then pass it to query.

  • Janae Cram 63 posts 437 karma points MVP 5x c-trib
    25 days ago
    Janae Cram
    100

    Hi Rene! I think if you change the x.GetProperty("tipoComunicazione").ToString() to x.Value<string>("tipoComunicazione"), that should make it work!

  • ReneRam 5 posts 45 karma points
    25 days ago
    ReneRam
    0

    Thanks a lot!

Please Sign in or register to post replies

Write your reply to:

Draft