Copied to clipboard

Flag this post as spam?

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


  • Dave de Moel 3 posts 43 karma points
    Jun 24, 2015 @ 07:01
    Dave de Moel
    0

    Umbraco 7 how to get data type of document property

    Hey guys I have a problem. Currently I am trying to get some code working that can add a child node to specific pages when they have a specific Document Type.

    To do this I want to be able to add a custom Data Type as a property to a Document Type to "flag" it to create a child node on save. However, I don't seem to be able to get the Data Type from the code behind, because the PropertyType Property of the Property class in Umbraco.Core.Models is not public.

    I want to avoid hardocded values in the code behind as much as possible so I can get a setup that is as flexible as possible, so I really want to be able to use the Data Type. So how can I access the Data Type of a given property?

    Below is an image of what I have so far. Basically I want to check if any property of the current node has the correct Data Type.

    Example of the current method

    EDIT: After further searching I found the answer myself. IContent also contains a seperate IEnumerable that contains all the available PropertyTypes on a given node, so my problem is solved.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jun 24, 2015 @ 12:08
    Jan Skovgaard
    0

    Hi Dave

    Happy to see you managed to figure out how to solve your issue.

    Could you post your "EDIT" as a new post? Then I'll be able to mark your answer as the solution so others can jump straight to it if they face the same issue. Right now it's not obvious that you figured it out.

    Happy coding btw! :)

    /Jan

  • Dave de Moel 3 posts 43 karma points
    Jun 24, 2015 @ 13:53
    Dave de Moel
    100

    After further searching I found the answer myself. IContent also contains a seperate IEnumerable that contains all the available PropertyTypes on a given node, so my problem is solved.

Please Sign in or register to post replies

Write your reply to:

Draft