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
Longhorn94Longhorn94 

Insufficient Privileges when calling VisualForce page with invalid id

This VisualForce page shows the account details for an account using an apex:detail object:

 

<apex:page standardController="Account">
          <apex:detail relatedList="false"/>
</apex:page>

 

Does anyone know why this page would show an error when you call it with an invalid account id in the url?  The error is:

 

Insufficient Privileges

You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.

 

The page works properly when you call it with an valid account id in the url.  I gave all roles permissions to view the page in the security definitions for the page, and I'm the admin in this developer account.

 

When other pages with a standard controller are called with an invalid account id, they return the VisualForce error:

 

Visualforce Error
Id value 001U0000005W2cu1 is not valid for the Account standard controller

 

Best Answer chosen by Admin (Salesforce Developers) 
Coco_SdyneyCoco_Sdyney

an valid account id should be 15 digits or 18 digits, yours is 16 digits, where you got this kind of Id from?

 

All Answers

Coco_SdyneyCoco_Sdyney

an valid account id should be 15 digits or 18 digits, yours is 16 digits, where you got this kind of Id from?

 

This was selected as the best answer
Longhorn94Longhorn94

Thanks, good catch, I had just entered the extra digit at the end to see how the page handles an invalid account id.  Leaving the account id at 15 digits but still with an account id that doesn't exist in my database (i.e. changing the account id in the url) results in the error I'd expect: Data Not Available.