Why is GetValue() extension returning Object reference not set error?
I have a very simple module that I created. I saved an item and published it and now I'm trying to retrieve the values but I'm getting an Object reference not set error when calling the GetValue() extension.
Can someone point help identify what's happening here?
var manager = DynamicModuleManager.GetManager();
var type = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Magazine.Magazine");
var id = new Guid(id);
var item = dynamicModuleManager.GetDataItem(type, id);
if (item != null)
var fullName = item.GetValue("FullName");
Hi Jeff,
I'm not sure about your module specifications regarding the fields, but try to do it like this:
var fullName = item.GetValue(
"FullName"
).ToString();
var fullName = item.GetValue<
string
>(
"FullName"
);
I had already tried that. Still gives the object reference not set error.
Hi Jeff,
You are sure that 'item' is actually not null?
Obvious of course, but just checking.
Kind regards,
Daniel
And if you are using localized fields, you should use this code:
var fullName = item.GetValue<LString>(
"FullName"
);
Yeah, sure. I can see the properties of item, like PubliscationDate and UrlName, when I debug.