Copied to clipboard

Flag this post as spam?

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


  • ReneRam 21 posts 186 karma points
    Sep 24, 2021 @ 14:46
    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 1593 posts 1824 karma points c-trib
    Sep 24, 2021 @ 16:31
    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 439 karma points MVP 7x c-trib
    Sep 24, 2021 @ 16:35
    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 21 posts 186 karma points
    Sep 24, 2021 @ 17:42
    ReneRam
    0

    Thanks a lot!

  • Brendan 3 posts 72 karma points
    Apr 07, 2022 @ 07:33
    Brendan
    0

    Thanks that worked!!

Please Sign in or register to post replies

Write your reply to:

Draft