Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Feb 25, 2016 @ 10:24
    Ismail Mayat
    0

    GetPropertyValue returns null

    Guys,

    I am using umbraco 7.3.3. On my doctype i have 3 mntp properties. I am also using https://our.umbraco.org/projects/developer-tools/umbraco-core-property-value-converters/ everything was working but now 2 of my properties always returns null. I am doing

    Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("travelTips")
    

    I also tried

    Model.Content.GetPropertyValue("travelTips")
    

    Also get null. I checked the xml config data is there and looks good. When i do

    Model.Content.GetProperty("travelTips").DataValue
    

    I get csv list of values.

    Any ideas?

    Regards

    Ismail

  • Ajay Karwal 31 posts 149 karma points
    Feb 25, 2016 @ 10:38
    Ajay Karwal
    0

    Have you tried iterating over the MNTP to see if any data comes out as outlined here?

    https://github.com/Jeavon/Umbraco-Core-Property-Value-Converters/blob/v2/Docs/MultiNodeTreePicker.md

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Feb 25, 2016 @ 10:42
    Dave Woestenborghs
    0

    Hi Ismail,

    Are the selected pages published ?

    Dave

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Feb 25, 2016 @ 11:10
    Ismail Mayat
    0

    Dave,

    They are, it seems to be failing with certain mntp fields so its running through property convertors and possibly failing. The xml is up to date I checked it also getting the raw value when not running through the property convertor i get the actual csv values set.

    Regards

    Ismail

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Feb 25, 2016 @ 11:29
    Dave Woestenborghs
    0

    I just had a brief look at the source.

    It should return null when you UmbracoContext.Current is null only ?

    https://github.com/Jeavon/Umbraco-Core-Property-Value-Converters/blob/v2/Our.Umbraco.PropertyConverters/MultiNodeTreePickerPropertyConverter.cs

    Dave

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Feb 25, 2016 @ 12:10
    Ismail Mayat
    0

    I am just stepping through code and mntp properties work except for 2 of my properties even though in xml there are ids in line:

      public override object ConvertSourceToObject(PublishedPropertyType propertyType, object source, bool preview)
        {
            // Get the data type "content" or "media" setting
            /*
            var dts = ApplicationContext.Current.Services.DataTypeService;
            var startNodePreValue =
                dts.GetPreValuesCollectionByDataTypeId(propertyType.DataTypeId)
                    .PreValuesAsDictionary.FirstOrDefault(x => x.Key.ToLowerInvariant() == "startNode".ToLowerInvariant()).Value.Value;
    
            var startNodeObj = JsonConvert.DeserializeObject<JObject>(startNodePreValue);
            var pickerType = startNodeObj.GetValue("type").Value<string>();
            */
    
            if (source == null)
            {
                return null;
            }
    
            var nodeIds = (int[])source;
    

    its null.

    This is really really weird

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Feb 25, 2016 @ 12:15
    Dave Woestenborghs
    0

    What happens if you disable the property value convertor ?

    You can remove it in the starting event

    PropertyValueConvertersResolver.Current.RemoveType<MultiNodeTreePickerPropertyConverter>();
    

    Do you get a list of id's when you do :

    Model.GetPropertyValue<string>("Your property")
    

    Dave

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Feb 25, 2016 @ 12:27
    Ismail Mayat
    0

    Dave,

    Not tried that but if i bypass the resolver by doing

    Model.GetProperty("travelTips").DataValue
    

    I get csv list of ids.

    So its there in the xml, I also checked the umbraco.config and it's there. I have raised issue here as well https://our.umbraco.org/projects/developer-tools/umbraco-core-property-value-converters/feedback//75391-some-mntp-properties-return-null I think it may be underlying umbraco issue with that particular property??

    Regards

    Ismail

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Feb 25, 2016 @ 14:40
    Ismail Mayat
    1

    Right mystery solved. Total epic fail on my part. The mntp target items live a couple of folders down in a parent folder called non page content. This was showing as being published but was actually not published as it was saying sorry not in xml cache. So republished that and all children now it all works.

    Please excuse me while i now go and bang my head against the wall #epicfail.

    Regards

    Ismail

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Feb 25, 2016 @ 14:41
    Dave Woestenborghs
    0

    Don't break the wall :-)

    Dave

  • Richard Hamilton 79 posts 169 karma points
    Dec 21, 2017 @ 12:08
    Richard Hamilton
    0
     var newsItems = new List<IPublishedContent>();
     Model.Content.GetPropertyValue<string>("newsItems").Split(',').ToList().ForEach(x => newsItems.Add(Umbraco.Content(x.ToString())));
    

    Just a bit of a work-around if you get stuck on this

    • But if I connect to my local database this method fails, on the live database the other one returns nulls. How can they be different?
  • Richard Hamilton 79 posts 169 karma points
    Dec 21, 2017 @ 15:39
    Richard Hamilton
    0

    ok - answer to my own problem. I was in the process of upgrading so my live one had a Property Editor of type: Umbraco.MultiNodeTreePicker and the local one was Umbraco.MultiNodeTreePicker2

Please Sign in or register to post replies

Write your reply to:

Draft