0

I've got a field in my template of type Time, the template is published and I've entered a value in my item but I'm not getting a value in my datasource.

I've tried DateTime and TimeSpan for the property type but all I get is default(T)

public virtual DateTime TimeOfDay {get;set;}

public virtual TimeSpan TimeOfDay {get;set;}

I've published the item and the template.

If I get the raw item via Sitecore.Context.Database.GetItem(...) I can see the field has a value, so it's entered and published properly, just not mapping. I've Googled but can't see anything relating to the Time field type.

What am I missing? How do I get the value to map to the glass model?

1
  • I'm not familiar with a Time field type. Is it a custom implementation? Commented Jan 21, 2019 at 13:04

1 Answer 1

4

This is a custom field. You can check this by going to core:/sitecore/system/Field types and looking at the field in question. It will most likely have a namespace that is part of your codebase in the assembly and class fields. What you need is a glass custom field mapper, this blog post explains it quite well...

https://sitecorecorner.com/2014/10/02/glass-mapper-and-custom-time-field/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.