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
Jessica LandismanJessica Landisman 

How can determine if current user has read/write access to an account

I have a dispatch Apex class that needs to determine whether a user has read/write or read-only rights for a particular Contact.  I did some reading online and found this link : http://wiki.developerforce.com/index.php/Testing_CRUD_and_FLS_Enforcement

 

 and based on that information, I used the following code:

 

Boolean isReadWrite = Schema.sObjectType.Contact.fields.name.isUpdateable();

 

The parameter isReadWrite is always returning false, even when the user is the owner of the account.

 

Any ideas on how to proceed?

 

Also, I need comparable functionality for Opportunities and Accounts, though I assume that all three use cases will follow the same general pattern.

 

jkeener.ax477jkeener.ax477
I think your first issue is because you are using the name field, vs. the FirstName and LastName fields. name is calculated and isn't updateable. The second issue you are going to run into is that you may be trying to figure out access for a "Specific" contact/account/etc, and what this is going to provide is general access (based on profile settings and field settings), not specific to the record you are dealing with. I'm not sure whether programatically it's possible to get to the specific records access. Jon Keener
Jessica LandismanJessica Landisman

I saw ESAPI http://code.google.com/p/force-dot-com-esapi/ - have you used this? Is there a native way to achieve the getUpdateableFields function in the ESAPI?