Try our conversational search powered by Generative AI!

Update ReadOnly Property during EventsPublishedContent


First, I want to add a readonly type property to my page type, is this possible? 
What I want is a string property that can be updated programicly, but not through the UI, and I would like the content editor to be able to see the value but not change it.

Assuming that is possible how do I update this property value during the Publish Event.

So how do I.... 

private void EventsPublishedContent(object sender, ContentEventArgs e)

     if (e.Content is MyPageType)

         var myvalue = BussinessLogic.PerformAction(e.content)

          //Now I want to save myvalue on to a property in 

Edited, Apr 13, 2018 17:15

How to make a readonly property

To edit this property and change the data call .CreateWritableClone() on the type e.g. e.Content.CreateWritableClone() as content is readonly until you do this (You may need to cast e.Content in to the type first to be able to access .CreateWritableClone()).

You can then IContentRepository's (inject this in to your code) method Save() to save this data. If you want to directly update it I would suggest SaveAction.Patch when saving as this doesn't create a new version.

Edited, Apr 13, 2018 18:08
* 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.