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
BartCBartC 

VisualForce Page + Customer Portal + Sites = sometimes Insufficient Privileges

Hi,

 

I have setup a customer portal and linked it with a site.  Everything is working except for 2 small things.

 

I show a visualforce page in the customer portal an it's displaying data in a <apex:pageblocktable and it's only showing a few rows by default (5).  Under this pageblocktable a have a <apex:commandlink .  When you click on this the controller is called and the rows limit is removed (from 5 to 0 so all records will become visible) using a pagereference method in the controller.  Sometimes this is working, sometimes i get an error Insufficient Privileges.

 

I also have a checkbox on that page that is communicating with the controller using actionSupport.  This checkbox will update a boolean field on the related account record.  Some problem here: sometimes it's working, sometime I get this error Insufficient Privileges.

 

BUT the record is always updated correctly.  So the problem must be in the Visualforce page (I think).

 

In the VisualForce page I also use rerender buet if I leave this out the problem is still ocurring

I also changed the API version to 18 (both for apex and vf) and to 19 and even 20.  Same result.

 

I always use the same customer portal user and in the controller I have many debug statements and no error is occurring there so the problem has to be on the page. 

 

I'm out of idea's.  So please HELP ! :)

 

Thank you.

 

Kind regards,

 

Bart

Pradeep_NavatarPradeep_Navatar

Generally the insufficient Privilege error comes when do not provided the field level Permission and CRUD permission to the profile. So make sure you are associating the right profile or providing the required permissions for your customer portal user.

BartCBartC

Thank you for the reply.

 

I will check this again, but the strange thing is that it sometimes works.  So when I do the same action 5 times in a row, it works 2 times and it's giving the error.

 

The fields are updated even when the error occurs.  So the code in the controller is executed well, but still the error occurs.

The code in the controller is like this and is executed well so the account is updated:

 

 

    public PageReference toggleShowDataToNeighbours() 
    {
        adapti_Functions.Error eError = new adapti_Functions.Error();
        try
        {
       system.debug('toggleShowDataToNeighbours is fired');
       system.debug('showDataToNeighbours : ' + showDataToNeighbours);
       if (this.showDataToNeighbours)
       {
oAccount.Tonen_bij_mijn_buren__c = 'Ja';
update oAccount;
   this.showDataToNeighbours = true;
            }else{
                oAccount.Tonen_bij_mijn_buren__c = 'Nee';
                update oAccount;
                this.showDataToNeighbours = false;
            }
            adapti_Functions.bubbleException();
            return null;
        }catch(Exception ex){
            eError = Adapti_Functions.CreateError(false, 'Error in cpConstructionProjectDetailController.toggleShowDataToNeighbours : ' + ex.getMessage());
            return null;                                   
        }
    }
I looks that the return null is causing this error.  Is there another way to call the controller from VisualForce and after the code is executed that some parts are rerendered without using PageReference?
Thank you.