Owner custom fields and some standard fields are not accessible in relations

I am trying to access owner information using soql for managed packaged sobject.

select id,ownerId,owner.name, owner.Email_Subscription__c from ARE__HavesWants__c

I tried above query but it is giving below error.

No such column 'Email_Subscription__c' on entity 'Name'

But when i removed owner.Email_Subscription__c it works, i.e. standard fields are accessible but custom fields are not accessible.

Is this any permission issue?
Please Help.

Answer

Unfortunately the Owner relation is a kind of strange.

Even if you prefix it the right way: it fails. This strange behavior seems not to be related to Managed Packages but the polymorphic nature of the Owner field. It was already noticed for some standard fields here.

Background

For Lead, Case, Knowledge article, Service contract and CustomObjects the Owner-field can not only be of type “User”, but also of type “Group”. Reason is, that the owner can also be a queue.

Like @PeterKnolle stated in the comment, in cases of such polymorphic foreign keys an SObject of type Name will be used.

So all this applies only, if you select owners of Cases or CustomObject and not if you do the same query on e. g. Account.

So this works:

SELECT Name, OwnerId, Owner.Name, Owner.Street FROM Account

while this doesn’t:

SELECT Name, OwnerId, Owner.Name, Owner.Street FROM YourPrefix__YourObject__c

Now if we recognize the polymorphism, what could be meaningful? I would expect to:

  • either be able to access all fields of both possible objects-types (merged, keeping the non-existent columns NULLed for the records of the other type)
  • or only those which are present in both (intersecting set of fields).

But the reality is different.

Status Quo

What I have tried so far, goes like this:

  • works:

    • 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
  • fails:

    • 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.Stree 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
    • Owne
    • 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

Attribution
Source : Link , Question Author : SFIntegrator , Answer Author : Community

Leave a Comment