You need to sign in to do that
Don't have an account?

History table query problem
CustomObject__History[] histories = [Select Id, CreatedDate, CreatedBy.user_id__c, Field, OldValue, NewValue FROM CustomObject__c
In Apex query, the system does not recognize the CUSTOM field on user called user_id and gives an error: No such column 'user_id__c' on entity 'Name'.
If I change it to SOME standard field like CreatedBy.Name, CreatedBy.Email or CreatedBy.UserName it works. It does NOT work for some standard fields such as Department, CommunityNickName etc. At first it appeared that it doesn't work for Nillable fields, but it works for FirstName and Title which is Nillable!
I am logged in as system admin and have all fields visible.
check the field level security for those fields.
Logged in as sys admin and have all fields visible.
I'm pretty sure this is related to the fact that the CreatedBy field on the history tables is Polymorphic. It's interesting because on standard / custom objects you can do what you're trying to do without a problem.
Here are a couple of things you can try:
Sean,
Thanks. I will try it out. It would appear to be that createdById is NOT polymorphic. The OwnerId can be (a user or a queue).
#2 is an option, but I am using this as part of Data Loader integeration where I am exporting transactions for a given object using History tables. I would really have to have another table on my SQL server to get the user id and do a join. I might just hack it with Title field it if does not work.