Recently I had a customer ask me for a rather simple feature – the ability to have Tridion folders and structure groups inherit the metadata schema and values from their parent. This would be only when creating new organizational items and obviously we want to show these default values on screen when editing.
And then it hit me that perhaps, just perhaps, I was making it more complex than it has to. After all, it’s just setting a default value, right? The Tridion CM Core team must have thought about this.
And indeed they have. The solution is so simple I almost feel ashamed I didn’t find it before.
EventSystem.Subscribe<OrganizationalItem, LoadEventArgs>(SetDefaultValues, EventPhases.Processed);
private void SetDefaultValues(OrganizationalItem subject, LoadEventArgs args, EventPhases phase)
if (subject.Id.IsUriNull) //Is new
OrganizationalItem parent = subject.OrganizationalItem;
if (parent.MetadataSchema != null && subject.MetadataSchema == null)
subject.MetadataSchema = parent.MetadataSchema;
subject.Metadata = parent.Metadata;