mar 192015

Salesforce – How to access Owner custom fields in a SOQL query?

Today I came across a problem with accessing Owner custom fields (for the User object I had several of these fields).

I only could access few standard fields like Owner.Name, Owner.FirstName without problems.

SELECT Id, Name, Owner.Name, Owner.FirstName, Owner.Store_Name__c
FROM CustomObject__c
WHERE Id = :ourId

ERROR at Row:1:Column:74
No such column ‚Store_Name__c’ on entity ‚Name’.

The solution was to create custom formula on our master object field that will reference custom Owner field.

Owner:User.Store_Name__c

Here the fields that can be used in SOQL query:
Owner.Name
Owner.Id
Owner.Type
Owner.Email
Owner.Username
Owner.LastName
Owner.FirstName
Owner.Title
Owner.Phone
Owner.Alias
Owner.UserRoleId
Owner.ProfileId
Owner.LastReferencedDate
Owner.Owner.LastViewedDate

and the ones that are not accesible:
Owner.AnyCustomField__c
Owner.DeveloperName
Owner.RelatedId
Owner.OwnerId
Owner.DoesSendEmailToMembers
Owner.DoesIncludeBosses
Owner.CreatedDate
Owner.CreatedById
Owner.LastModifiedDate
Owner.LastModifiedById
Owner.SystemModstamp
Owner.CompanyName
Owner.Division
Owner.Department
Owner.Street and all other Adress-Fields
Owner.Longitude and Latitude
Owner.StayInTouchNote
Owner.StayInTouchSignature
Owner.StayInTouchSubject
Owner.Signature
Owner.SenderName
Owner.SenderEmail
Owner.EmailPreferencesStayInTouchReminder
Owner.EmailPreferencesAutoBccStayInTouch
Owner.Fax
Owner.MobilePhone
Owner.CommunityNickname
Owner.Active
Owner.TimeZoneSidKey
Owner.LocaleSidKey
Owner.ReceivesInfoEmails
Owner.EmailEncodingKey
Owner.ReceivesAdminInfoEmails
Owner.OfflineTrialExpirationDate
Owner.LastPasswordChangeDate
Owner.LastLoginDate
Owner.ManagerId
Owner.DelegatedApproverId
Owner.EmployeeNumber
Owner.LanguageLocaleKey
Owner.UserType
Owner.DefaultGroupNotificationFrequency
Owner.DigestFrequency
Owner.SmallPhotoUrl
Owner.FullPhotoUrl
Owner.AboutMe
Owner.FederationIdentifier
Owner.Extension
Owner.CallCenterId
Owner.AccountId
Owner.ContactId
Owner.UserPreferencesHideS1BrowserUI
Owner.UserPreferencesShowCountryToGuestUsers
Owner.UserPreferencesShowPostalCodeToGuestUsers
Owner.UserPreferencesShowStateToGuestUsers
Owner.UserPreferencesShowCityToGuestUsers
Owner.UserPreferencesShowTitleToGuestUsers
Owner.UserPreferencesShowProfilePicToGuestUsers
Owner.UserPreferencesShowCountryToExternalUsers
Owner.UserPreferencesShowPostalCodeToExternalUsers
Owner.UserPreferencesShowStateToExternalUsers
Owner.UserPreferencesShowCityToExternalUsers
Owner.UserPreferencesShowStreetAddressToExternalUsers
Owner.UserPreferencesShowFaxToExternalUsers
Owner.UserPreferencesShowMobilePhoneToExternalUsers
Owner.UserPreferencesShowWorkPhoneToExternalUsers
Owner.UserPreferencesShowEmailToExternalUsers
Owner.UserPreferencesShowManagerToExternalUsers
Owner.UserPreferencesShowTitleToExternalUsers
Owner.UserPreferencesDisableFileShareNotificationsForApi
Owner.UserPreferencesEnableAutoSubForFeeds
Owner.UserPreferencesDisableSharePostEmail
Owner.UserPreferencesDisableBookmarkEmail
Owner.UserPreferencesOptOutOfTouch
Owner.UserPreferencesDisableMessageEmail
Owner.UserPreferencesDisableLikeEmail
Owner.UserPreferencesDisCommentAfterLikeEmail
Owner.UserPreferencesHideSecondChatterOnboardingSplash
Owner.UserPreferencesHideChatterOnboardingSplash
Owner.UserPreferencesHideCSNDesktopTask
Owner.UserPreferencesDisMentionsCommentEmail
Owner.UserPreferencesDisableMentionsPostEmail
Owner.UserPreferencesHideCSNGetChatterMobileTask
Owner.UserPreferencesApexPagesDeveloperMode
Owner.UserPreferencesContentEmailAsAndWhen
Owner.UserPreferencesContentNoEmail
Owner.UserPreferencesDisProfPostCommentEmail
Owner.UserPreferencesDisableLaterCommentEmail
Owner.UserPreferencesDisableChangeCommentEmail
Owner.UserPreferencesDisableProfilePostEmail
Owner.UserPreferencesDisableFollowersEmail
Owner.UserPreferencesDisableAllFeedsEmail
Owner.UserPreferencesReminderSoundOff
Owner.UserPreferencesTaskRemindersCheckboxDefault
Owner.UserPreferencesEventRemindersCheckboxDefault
Owner.UserPreferencesActivityRemindersPopup
Owner.ForecastEnabled
Owner.UserPermissionsChatterAnswersUser
Owner.UserPermissionsSiteforcePublisherUser
Owner.UserPermissionsSiteforceContributorUser
Owner.UserPermissionsSupportUser
Owner.UserPermissionsInteractionUser
Owner.UserPermissionsKnowledgeUser
Owner.UserPermissionsSFContentUser
Owner.UserPermissionsMobileUser
Owner.UserPermissionsCallCenterAutoLogin
Owner.UserPermissionsOfflineUser
Owner.UserPermissionsMarketingUser
Owner.OfflinePdaTrialExpirationDate

Tagged with , , , 0 komentarzy

Dodaj komentarz

Your email address will not be published. Please enter your name, email and a comment.