3

Getting Unknown Exception while querying 'UserEntityAccess' in work bench,

Query :

SELECT
    EntityDefinition.Id,EntityDefinition.DurableId,
    EntityDefinition.QualifiedApiName, EntityDefinition.MasterLabel
FROM UserEntityAccess
WHERE UserId='xxxxxxxxU75'
AND EntityDefinition.qualifiedApiName= 'xx__c'

URL :

/services/data/v36.0/query?q=SELECT+EntityDefinition.Id,EntityDefinition.DurableId,EntityDefinition.QualifiedApiName,EntityDefinition.MasterLabel+FROM+UserEntityAccess+WHERE+UserId='xxxxxxxxxxU75'+and+EntityDefinition.qualifiedApiName=+'xx__c'

  • 1
    try to execute same query in developer console, doing so You will get the error code, and then contact salesforce support . – C0DEPirate May 2 '16 at 13:33
  • yes I am getting the errorID but am I doing the correct thing here? – Saumya Ranjan Satapathy May 2 '16 at 13:37
  • definitely something is incorrect, since you are getting error id, I believe it is very difficult to tell whats wrong here – C0DEPirate May 2 '16 at 13:46
  • I reproduced it. Got back the GACK Error ID: 481405300-62604 (-1680970010) Do you have Premier support to raise it as a case? – Daniel Ballinger May 3 '16 at 0:01
2

I suspect you can't use EntityDefinition in the SOQL where clause like that against UserEntityAccess.

From the linked docs:

Field
EntityDefinition

Details - Description
The entity definition for the object associated with this user entity access record. Because this field represents a relationship, use only in subqueries.

  • Thanks @Daniel. I tried using DurableID field on the UserEntityAccess object itself instead of durableId on EntityDefinition. But I don't know why even that is not woking. – Saumya Ranjan Satapathy May 3 '16 at 3:22
  • Can you please tell me how to query, what level of access a user has to a particular object, using either UserEntityAccess or any other object? And I saw durableId on UserEntityAccess is using some pattern like <i>APIName.entityDefinitionDurableID</i>. Do you know what is that pattern and how to query that. – Saumya Ranjan Satapathy May 3 '16 at 3:27
  • @SaumyaRanjanSatapathy Typically you would check the level of access for an individual record id or a set of record ids. See Can I find out if the current user has access to a record without querying? – Daniel Ballinger May 3 '16 at 8:03
  • @SaumyaRanjanSatapathy You can also reverse how the query is down from v30.0 onwards. SELECT Id, Name, UserRecordAccess.HasReadAccess, UserRecordAccess.HasTransferAccess, UserRecordAccess.MaxAccessLevel FROM Account – Daniel Ballinger May 3 '16 at 8:06
  • Hi Daniel. To much surprise query in my question is running fine today, I don't know how. But thanks a lot for your help. And my requirement is like, a super user wants to see all the users and their access level to a perticular object. So I think using UserEntityAccess will only help me. – Saumya Ranjan Satapathy May 10 '16 at 10:39

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.