+ Start a Discussion
M. J. KahnM. J. Kahn 

How to determine whether a user has write access to a record

Is there any way in Apex to determine whether the current user has write access to a record?
 
I know I could try to update the record and if an exception is thrown, I'd know that the current user doesn't have write access to the record, but if an exception isn't thrown, then I'll have updated the record, changing its Modified Date, and I'd rather not do that.
 
There's a similar question ("Determine whether a user has edit rights through API" - http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=2280&query.id=43418) dated January 2008. The response says, "We're looking into adding this capability," and I'm wondering whether it has been added.
 
Thanks!
 
 
 
BudVieiraBudVieira

Hi M. J.,

 

You are not alone in wanting this ability, and we still have this on our radar. It's currently not on our release schedule however. Can you tell me more about why you need this access? Perhaps we can find another solution together.

 

Cheers,

 

Bud Vieira

PM Sharing

 

MJ09MJ09

Thanks for your reply!

 

I have a custom object that has some custom JavaScript detail buttons. Any user can look at records for this object, but when a user clicks one of the buttons for a record, the button should do its thing only if the user is the Record Owner or above the Record Owner in the Role Hierarchy. I know I can write a whole bunch of Apex code to figure this out, and then have my button call it as a webMethod, but that seems like a lot of work for what seems like a pretty simple question ("Is the current user above the owner of this record?").

 

I'm a little surprised that there isn't already an Apex method to determine whether one user is above or below another user in the Role Hierarchy. Of course, when we're talking about record owners, it gets little more complex, since they can be either users or groups, but still, it doesn't seem that unusual a requirement.

 

Even if this isn't part of the standard product, it might be useful for someone at Salesforce to post a solution as a blog entry or in the wiki so it's available for all to see and use.

 

Thanks!

 

MJ.