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

10

1

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.

SFIntegrator

Posted 2014-08-21T13:16:51.480

Reputation: 736

1did you check the Field Level Security of the field Email_Subscription__c to see if your profile has access to it ? – Vamsi Krishna – 2014-08-21T13:39:37.403

Answers

11

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

Uwe Heim

Posted 2014-08-21T13:16:51.480

Reputation: 21 301

1

The fields that work should be those on the Name object. The Owner field has namePointing equal to true.

– Peter Knolle – 2014-08-21T17:12:54.080

@PeterKnolle : YES that's it! Today I run into that issue while using my custom.query() function which does stuff like SELECT *, Owner.*, CreatedBy.* FROM WhatEver and I lost hours... I will update my answer. Thanks Peter! – Uwe Heim – 2014-08-21T17:19:41.147

1

Since that question is still actual, i find helpful to share the way around i found for myself to filter records by Owner's custom field value.

My goal was to filter activities by owner's Primary Function which is a custom picklist field.

So i added a custom formula field named Owner_Primary_Functions__c to Activities object to represent the field value from related User objects for Task records. In my case the formula was TEXT(Owner:User.Primary_Functions__c).

Now this query works for me:

SELECT Id, Subject, Owner.Name, Owner_Primary_Functions__c FROM Task

hlopetz

Posted 2014-08-21T13:16:51.480

Reputation: 142