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.
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");
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.
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:
But this is returning null, I know the alias is correct, so what could be wrong?
It results in a System.NullReferenceException: Object reference not set to an instance of an object.
Thanks,
Greg.
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:
HTH,
Hendy
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
Anyone know why since 4.8, I am on 4.9 actually that 'HasProperty' is not recognized?
Thanks'
is working on a reply...