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
ForceLoverForceLover 

How to know whether current login user has edit permission to lead object or not in Apex

Hi Everyone.

 

I want to know current login user has edit permission to lead object or not ...

 

Thanks in Advance

Best Answer chosen by Admin (Salesforce Developers) 
empucempuc

Sorry I forgot about brackets....

 

Schema.DescribeSObjectResult R = Lead.SObjectType.getDescribe();
boolean canAcess=R.isAccessible();
boolean canCreate=R.isCreateable();
boolean canUpdate=R.isUpdateable();
boolean candelete=R.isDeletable();

All Answers

empucempuc

To check any type of Lead access, You can try following statements:

 

Schema.DescribeSObjectResult R = Lead.SObjectType.getDescribe();
boolean canAcess=R.isAccessible;
boolean canCreate=R.isCreateable;

boolean canUpdate=R.isUpdateable;

boolean candelete=R.isDeletable;

 

It returns information based on currently logged user in context of which operation is performed. 

 

Happy easter! :)

ForceLoverForceLover
HI
Thanks for replying it is giving me an error
ConvertLeadsController Compile Error: Expression of type Schema.DescribeSObjectResult has no member named isCreateable
empucempuc

Sorry I forgot about brackets....

 

Schema.DescribeSObjectResult R = Lead.SObjectType.getDescribe();
boolean canAcess=R.isAccessible();
boolean canCreate=R.isCreateable();
boolean canUpdate=R.isUpdateable();
boolean candelete=R.isDeletable();

This was selected as the best answer
ForceLoverForceLover
Sorry even i don't check it
anyway it is saved..