Copied to clipboard

Flag this post as spam?

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


  • Dallas 132 posts 404 karma points
    Jun 16, 2017 @ 15:44
    Dallas
    0

    null property values in GatheringNodeData

    Hi

    I am trying to get a document in the GatheringNodeData event using TypedContent. I am able to get an instance of the document but all of the Property values are null.

    Here is a snippet of the relevant code. Note that I am using the fake Umbraco Context to create the helper.

     private void OnGatheringNodeData(object sender, IndexingNodeDataEventArgs e, UmbracoHelper helper)
            {
                // Get document
                var doc = helper.TypedContent(e.NodeId);
    
                // we are trying to get a value out of a NestedContent property to index so it can be searched on
                // this logs an exception to the Umbraco log as the property value is null. 
                var prop3 = doc.GetPropertyValue<IEnumberable<IPublishedContent>>("prop"); 
    
                var prop = doc.GetProperty("prop").Value; // value is null
                var prop1 = doc.GetProperty("prop").DataValue; // has the raw json value
    
                // we are using models builder so this is also null
                var prop2 = doc.Prop;  
            }
    

    @sniffdk provided an alternative solution to indexing the nested content values on the slack channel but I am still curious if this should be possible.

    Dallas

  • Ali 5 posts 74 karma points
    Aug 09, 2017 @ 17:38
    Ali
    0

    i have the same issue, i am get GetPropertyValue as null but the umb://media value is availble in DataValue, how do i get the url?

  • Dallas 132 posts 404 karma points
    Aug 18, 2017 @ 02:16
    Dallas
    1

    I was able to solve the problem by defining the UmbracoHelper in the OnGatheringNodeData() method rather than passing it in as a parameter.

    Dallas

Please Sign in or register to post replies

Write your reply to:

Draft