Copied to clipboard

Flag this post as spam?

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


  • Greg Fyans 140 posts 342 karma points
    Aug 20, 2012 @ 14:31
    Greg Fyans
    0

    Member.getProperty always returns null

    Hi,

    Umbraco 4.8.1

    I am trying to load a member's properties using the getProperty method on umbraco.cms.businesslogic.member.MemberType.

    I can load the member just fine using:

    var member = new umbraco.cms.businesslogic.member.Member(1111);

    But this is returning null, I know the alias is correct, so what could be wrong?

     

    var member = new umbraco.cms.businesslogic.member.Member(1111);
    var memberPropertyType = new umbraco.cms.businesslogic.member.MemberType(1110).getPropertyType("systemGoals"); var memberSystemGoals = member.getProperty(memberPropertyType).Value;

    It results in a System.NullReferenceException: Object reference not set to an instance of an object.

    Thanks,
    Greg.

     

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Aug 20, 2012 @ 14:48
    Hendy Racher
    0

    Hi Greg,

    It's difficult to tell which object may be null without stepping though, as your code looks correct - do both the member and memberPropertyType variables get set correctly ?

    Since you're using Umbraco 4.8+ you could also use the uQuery helper:

    using umbraco;
    string systemGoals = uQuery.GetMember(1111).GetProperty<string>("systemGoals");
    

    HTH,

    Hendy

  • Greg Fyans 140 posts 342 karma points
    Aug 20, 2012 @ 16:03
    Greg Fyans
    0

    Hi,

    Yea the member and member property type objects are there, I can step into each and see their properties.

    That uQuery seems to work which is odd as I'm assuming it's a wrapper for what I've already done.

    I'm not ruling out a dodgy Umbraco install, I have been getting some strange exceptions when attempting to install packages that have worked previously. I may try a re-install and see if that fixes it.

    Thanks,
    Greg 

  • Carlos 338 posts 472 karma points
    Oct 19, 2012 @ 21:40
    Carlos
    0

    Anyone know why since 4.8, I am on 4.9 actually that 'HasProperty' is not recognized?  

     

    Thanks'

Please Sign in or register to post replies

Write your reply to:

Draft