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
RSTRST 

How to get User not having access Error on New button click on Account.

Hi,

 

I have a "New Account" button on Account object.

this new Account button redirects to another visualforce page.

 

Now, i want When a user clicks the "New Account" button on the Account Page Layout and they do not have the "Create" permission on their user profile or granted through permission sets, the following error message is displayed: "You have insufficient privileges to create Accounts".

dhelmerdhelmer

Check out the Apex Guide page Enforcing Object and Field Permissions.

 

if (!Schema.sObjectType.Account.isCreateable()) {
   // Logic to display your error message
}

 

RSTRST

Thanks for your reply....

 

i think Schema.DescribeSObjectResult.isCreateable() will work....but can you tell me where should i use it...i mean on button or vf page??

or

I need to write any trigger or class for it?

dhelmerdhelmer
Well it depends on what you want to have happen when they DO have permission.