Copied to clipboard

Flag this post as spam?

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


  • Chris Barber 11 posts 109 karma points
    Jun 16, 2023 @ 09:36
    Chris Barber
    0

    Finding only the DropDown prevalues that are being used

    Hi, What is the best way to get only the DropDown prevalues that are currently being used/have dependencies?

    For example: With a given list of Document Categories enter image description here

    The following code gets all the Document Categories:

    var categories = DataTypeService.GetDataType(DropDownListIds.DocumentCategories)?.Configuration as DropDownFlexibleConfiguration;
    

    Is there a way to only retrieve the prevalues that are being used (e.g. if there are no 'Policies' documents there is no point in displaying the option in the dropdown)?

    Thanks in advance

  • Daniel 18 posts 108 karma points
    Jun 19, 2023 @ 17:43
    Daniel
    0

    Hi, I'm not 100% sure if you are simply trying to find the selected values in a dropdown or if you are creating a service that looks for all the uses of this property globally within a solution.

    If you are only looking for the selected values in a view, it should be as simple as referring to the documentation

    var selectedValues = Model.Value<IEnumerable<string>>("DropDown");
    
  • Chris Barber 11 posts 109 karma points
    Jun 20, 2023 @ 07:34
    Chris Barber
    0

    Hi Daniel, Thank you for your reply. It is the latter situation that I had in mind. Is there a 'out of the box' way to create a service that finds all the uses of this property globally within a solution?

  • Daniel 18 posts 108 karma points
    Jun 22, 2023 @ 11:37
    Daniel
    100

    Hi again.

    Don't know if there is a service for it, but I found it using some database queries.

    Assuming that you use Umbraco 11, you could use this:

    SELECT * FROM cmsPropertyType
    where Alias = 'DocumentCategories'
    

    Use the returned Id from this list that matches your property editor: (296 is a dummy number)

    SELECT *
    FROM umbracoPropertyData
    WHERE propertyTypeId = 296
    

    That should get you all the data of where the property editor is used.

    Hope it helps you create your service :)

  • Chris Barber 11 posts 109 karma points
    Jun 22, 2023 @ 12:07
    Chris Barber
    0

    thanks, I'll give it a try

Please Sign in or register to post replies

Write your reply to:

Draft