Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Phil Whittaker 63 posts 267 karma points MVP 4x c-trib
    Nov 03, 2017 @ 07:37
    Phil Whittaker
    0

    Custom property editor return null on Frontend

    I have created a custom property editor that contains a reasonably complicated object. I use PropertyConvertor.ConvertDataToSource to parse the json and return it as the poco object via deserialisation

    [PropertyValueType(typeof(PropertyEditor))]
        [PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)]
        public class PropertyConvertor : PropertyValueConverterBase
        {
            public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
            {
                if(source != null)
                {
                    try
                    {
                        return JsonConvert.DeserializeObject<PropertyEditor>(source.ToString());
                    }
                    catch { }  
                }
                return source;
            }
    
            public override bool IsConverter(PublishedPropertyType propertyType)
            {
                return propertyType.PropertyEditorAlias.Equals("PropertyEditor");
            }
        }
    

    All works well and it seemed to be a fairly simple solution. However we are seeing an issue where occasionally the object on the front end will suddenly become Null and the page will crash. The data is still present in the backend and if we re-publish everything is fine.

    Does anyone know what could be causing this?

Please Sign in or register to post replies

Write your reply to:

Draft