I'm trying to get the creator of an item, but when I access the CreatedBy property, it returns an empty string. When I debugged I could see the all the other fields were populated, but not the CreatedBy:

enter image description here

var contextDatabase = Sitecore.Context.Database;
Item blogPost = contextDatabase.GetItem(data.ID);
var creator =  blogPost.Statistics.CreatedBy;

I really don't know why it shows as empty. Any idea why?

Edit: In the content tree, in the statistic field section, the CreatedBy is there:

enter image description here

  • 1
    can you try in this way: blogPost.Fields["__created by"].Value – Vlad Iobagiu Oct 20 '17 at 15:13
  • @SitecoreClimber Yeah that worked, thanks. I still dont understand why the other way doesnt work, that;s weird. – Joel Alvarez Myrrie Oct 20 '17 at 15:25
  • 1
    I am transforminng my comment in an answer. – Vlad Iobagiu Oct 20 '17 at 15:28

"Statistics.CreatedBy" property does not return standard values.

To fix this problem please use : blogPost.Fields["__created by"].Value

Statistics.Created use next code:

private string GetFieldValue(ID fieldId)
    Field field = this._item.Fields[fieldId];
    return field.GetValue(false, false) ?? string.Empty;

where field.GetValue has next parameters

public virtual string GetValue(bool allowStandardValue, bool allowDefaultValue)
  • Wut? :D So if Creator happens to be the same account as the one who created the Standard Values item, this applies? – Mark Cassidy Oct 20 '17 at 15:37
  • Oh I see, thanks really!. Do you know where can I get the API documentation. I've looked for it everywhere, with no luck at all. – Joel Alvarez Myrrie Oct 20 '17 at 15:38
  • Also, why is it there? the "Statistics.CreatedBy" if it's not gonna be used? – Joel Alvarez Myrrie Oct 20 '17 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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