We have moved to GitHub Issues
Created by Jesper Ordrup 25 Nov 2013, 10:53:42 Updated by Shannon Deminick 26 Nov 2013, 02:38:37
Ive installed Umbraco 7 using VS + nuget and captured ContentService.Created, ContentService.Creating & ContentService.Publishing. It seems that the two create related Events are never thrown as none of my breakpoints are hit. In the publicing event my breakpoints are hit.
I dont know if its a bug or just changed behavior as in U 7 we dont create it before we save it I guess Before - we actually named and created a node before editing and then saving.
If thats the case - how do we add initial values to fields from events?
Any chance you can test this with v6, so using the same events, does that work in that version?
Sure thing .. I just did. Result is that both events created and creating fire when expected. I used a 6.16 version and the exact same code that didnt work in 7.0.0
Cool thanks for testing!
The Created and Creating events will be obsoleted, they really shouldn't be used because you cannot guarantee that everyone will use the ContentService.CreateContent method instantiate a new IContent instance. This event was created only for backwards compatibility with the legacy API. The Saving event will execute for new and existing content, you should use that event instead and you can easily check if the IContent is new by checking HasIdentity.
We will fix our ContentController to use CreateContent to instantiate new content so this event will fire but it will be obsoleted (and eventually removed from the codebase in some future major versions) so recommend to not use it and use Saving instead.
The only benefit of this event (which is only relavent for v7) is that we will use the CreateContent method to instantiate the new IContent which is used to transform to the display model when creating new content - this therefor would allow you to have default values shown in the editor before saving a new item.
However... we will be introducing controller events to modify the model before being shown in the editor (in 7.1) which is how you should do this.
And one last problem with this event and inconsistency is that we can only use the CreateContent method to create a new IContent to be shown to the editor which will show the default values to the editor, it will not be used when actually saving the new content item when we POST to the PostSave controller action. This is because if we did that, whatever data the editor types in would be overwritten by the values you put in the content in Creating/Created events. So if you want to force data in there and override what the editor has put in, you'd still need to use Saving.
I realize this might all be confusing, and it is - this event should just not exist.
done in 03a606432ae8baa76b43e453535a1f6be88a55f7
Assignee: Shannon Deminick
Backwards Compatible: True
Affected versions: 7.0.0
Due in version: 7.0.1