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?
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?
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
Hi iNETZO,
That is exactly what I'm after... thank you very much for pointing me there!
is working on a reply...