function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

UserRecordAccess object is not working for running user

Hi Guys,

I have a custom button, in that button i am querying the record from UserRecordAccess  object using AJAX script to know the current user is having the edit access or not  on the particular record.
If user is having the edit access then only i am doing some operations. It is working fine as a system admin. but when the end user click on the button it is showing error Invalid Type sobject.
It is not working for the running users. please suggest on this. Other than the UserRecordAccess object, is there any other way to know the record access.


What version of the API is the included JavaScript?  The UserRecordAccess was introduced in API version 24, so if yours is earlier than that you will get this error.
Hi bob,

I have tried upto 33.0 API version but it is not working and the API enabled option is checked for that running user as well. It is working fine for system admin. And while page is refreshing if we click the button immediately then it is working fine but after page load it is not working.

Can we run the ajax script with a specific user like system.runas()

Hi Bob,

I have created a method and executed from the button then it is working fine.

Project tcsProject tcs
Hi Krish,

i m facing the same problem. i didnt use any azax. In my case a method is  called from a lightning button. When i ran the query as a sysAmdnin i get a specfic user has read access false but when i ran the same code after login with that user it shows it has read access. So if you can share your solution it will help.