I need to create a custom Clone button to clone only data fields in which the logged in user has view permission to (in the his assigned permission set). how do I do that using the Apex class?



There are two ways to do it.

1 Using sObjectDescribeResult class:

Take object Account for instance, you can do something like this.

Schema.DescribeFieldResult dfr = Account.Description.getDescribe();
dfr.isAccessible(); //tells if the current user has acces to it or not.

2 Using SOQL:

Please refer to the following Salesforce blog: https://developer.salesforce.com/blogs/engineering/2012/06/using-soql-to-determine-your-users-permissions-2.html

  • 3
    Please include an example for 2 as well. Users should not have to follow any links off site for an answer to be effective. – Adrian Larson Dec 29 '17 at 14:31

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.