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

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



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".


As per my understanding you would like to Restrict the profile person to create a new account? 

If thats the case you can imply Sharing settings to the particular Roles.


Let me know if that is not the case you are looking for..

Venkat PolisettiVenkat Polisetti

Do that check in your Visualforce page and Custom controller or Controller Extension.


NOTE: Untested code below.


  1. On your visualforce page, put a page action an wire it up call the controller method. 

                  <apex:page controller="AcountCustomController" action="{!checkAccess}" >

                             <apex:outputpanel rendered="{!NOT(hasCreateAccess)}">

                                     YOU DO NOT HAVE CREATE ACCESS TO ACCOUNTS




 2. In your controller:

               public class AcountCustomController {

                       public hasCreateAccess {get;set;}


                      public AccountCustomController() {

                               hasCreateAccess = false;



                       public Pagereference checkAccess() {

                                  if (Schema.SobjectType.Account.isCreateable())

                                              hasCreateAccess = true;




I guess, you get the point here. Let me know how it goes.