Copied to clipboard

Flag this post as spam?

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


  • Keith Boynton 19 posts 61 karma points
    May 24, 2020 @ 11:03
    Keith Boynton
    0

    Creating a default value for a doctype property

    I have a blog article doctype with an author name field on it. I'd like to pre-populate that field with the name of the user who is logged in to the back office and is creating the blog article.

    After digging around I found a couple of posts on here explaining how to do it in earlier versions of Umbraco but those ways don't seem to be supported in U8.

    I had looked into creating a component that uses the ContentService and hooks into the Created event, like the pre 8 solutions seemed to do. However that event doesn't appear to be available in 8.6.1.

    Content Templates don't look like they will be right for the job because they look to be more about creating skeleton documents and it still wouldn't be something that pre-populates based on the logged in user.

    My question is how can you set default values for doctype properties based on code?

  • iNETZO 133 posts 496 karma points c-trib
    May 24, 2020 @ 13:01
    iNETZO
    100

    Hi Keith,

    I usually use EditorModel Events here to get this done. The documentation can be found here: https://our.umbraco.com/documentation/reference/events/EditorModel-Events/

    I think the documentation describes pretty well how this should be done, but if you can't figure it out please let me know.

    Best regards,

    iNETZO

  • Keith Boynton 19 posts 61 karma points
    May 24, 2020 @ 20:07
    Keith Boynton
    0

    Hi iNETZO,

    That is exactly what I'm after... thank you very much for pointing me there!

Please Sign in or register to post replies

Write your reply to:

Draft