Setting and Saving Dynamic Properties in code

Vote:
 
Hi, I'm struggling to persist changes to a dynamic property on a page. I have an event handler hooked onto the CreatedPage event. I also have a dynamic property defined called guidIdentity. In the event handler I want to set this dynamic property to the value of a new guid and persist this change. I have the following code in the event handler: DataFactory.DynPropTree.SetDynamicProperties(pageData); string guid = Guid.NewGuid().ToString(); pageData.Property["guidIdentity"].Value = guid; EPiServer.Global.EPDataFactory.Save(pageData,EPiServer.DataAccess.SaveAction.Publish); When i view the page in edit mode and edit dynamic properties the value is empty. Any ideas why this is the case? Many thanks.
#12883
Jan 02, 2007 10:24
Vote:
 
Ah, it seems that although the dynamic property appears to be a property, that in fact is not really the case when it comes to changing the value. There is a another, somewhat undocumented, way to update a dynamic property in code. The following works: DynamicPropertyCollection dynaprops = DynamicProperty.ListForPage(e.PageLink); DynamicProperty dp = dynaprops["guidIdentity"]; dp.PropertyValue.Value = "some value"; DynamicProperty.SaveCollection(e.PageLink, dynaprops); An addition to the book/ docs on this would be useful. All the examples are read only and give the impression that dyna props work the same way as normal properties.
#15032
Jan 02, 2007 12:16
Vote:
 
You know that all pages have a GUID? If you didn't Regards HAXEN
#15033
Jan 03, 2007 17:48
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.