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?
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
There are two ways to do it.
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.
Please refer to the following Salesforce blog: https://developer.salesforce.com/blogs/engineering/2012/06/using-soql-to-determine-your-users-permissions-2.html