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
amitashtekaramitashtekar 

page is showing insufficient privilege

 

 

 

I have developed a daily poll component for the force.com based site.

 

I have used customer portal to authenticate users.

I have added that component within the right hand template.

<apex:component allowDML="true" controller="cybVotePoll" id="Poll">

<apex:pageBlock title="Today's&nbsp;Poll" id="PollPageBlock" mode="edit">

<apex:panelgrid id="Graph" columns="1">

<apex:outputLabel value="{!PollQuestion}"style="font-size:12px;font-style:italic;color:#0000ff;font-weight:bold;" />

<apex:outputLabel value="{!Msg}" style="color:#ff0000;" id="msg" />

<apex:form >

<apex:selectRadio value="{!UserVote}" id="ResponsePanel" disabled="{!DisableOptions}">

 <apex:selectOptions value="{!ResponseOptions}" />

<apex:actionSupport event="onclick" action="{!SubmitVote}"rerender="ResponsePanel,msg,OutputResult" status="test" />

 </apex:selectRadio>

</apex:form>

<apex:actionStatus id="test" startText="submitting vote..." />

<apex:image width="200" height="150" url="{!ResponseUrl}"id="OutputResult" />

<apex:form >

<apex:commandLink action="{!showPastResults}"value="Past Results >>" />

</apex:form>

</apex:panelgrid>

</apex:pageBlock>

</apex:component>

  

Whenever the radio option is selected on the page, it shows error page with error as insufficient privilege.

I have removed all ther crud rights from the profile so that user could not get access to salesforce standard pages.

Please any one guide me on this issue.

Best Answer chosen by Admin (Salesforce Developers) 
DaveLDaveL

For future readers so you avoid the same silly mistake I made.  I was getting this same issue.  I could navigate to the page and display it, but any action (rerender, even a commandbutton submit) would cause the Insuficient Privilege error.

 

The problem was that I created this new page via Eclipse (force.com ide) and of course the PAGE SECURITY was set by default to my sysadmin profile only. AFAIK there is no way to affect that via the ide.  I just had to jump onto SFDC proper, go to Develop | Pages and find my page, click Security and add the needed (portal user) profiles.

 

The interesting thing is that SFDC doesn't throw this error on the first render of the page (which I got to via the "PageReference P = new PageReference... " syntax in a controller).....only on the first attempt to interact with it, which includes attempts at ajax rerender calls.  Which is why I chased my tail for a 1/2 day.

All Answers

Ryan-GuestRyan-Guest

Where do you redirect people to after a submit?

 

Also, check the CRUD and FLS of the profile.

amitashtekaramitashtekar

Hi,

Thanks for reply.

I have removed the CRUD rights of those two objects, Poll and PollResponse from the customer portal user's profile. So that user can not get access to any standard pages which are displayed if we append record id or object id to url.

Field level security for fields of both objects is visible(i.e. read/write).

The user is not redirected to any page. I have tried it with return types void, pagereference. Still the problem persists. 

joshbirkjoshbirk

You also get insufficient privileges from a normal Apex error.  Visualforce doesn't render Apex errors for Sites users as it does for native users, so you may try debugging the VF as a native user as well.

amitashtekaramitashtekar

I am adding the component code and controller code. If I add this component within a page. It is showing me insufficient previledges.

 

<apex:component allowDML="true" selfClosing="true" controller="Poll" rendered="true">
    <apex:pageBlock title="today's poll">
        <apex:form>
            <apex:panelgrid columns="2">
                <apex:outputlabel value="{!PollQuestion}"  />
                <apex:outputLabel value="{!UserVote}"/>
                <apex:selectRadio  value="{!UserVote}" disabled="{!FlagVoted}" >
                    <apex:selectoptions value="{!PollOptions}"></apex:selectoptions>
                    <apex:actionsupport action="{!SubmitVote}" rerender="UserVote,PollOptions,SubStatus" event="onclick" status="SubStatus"/>
                </apex:selectRadio>
                <apex:actionstatus id="SubStatus" StartText="submitting vote..." ></apex:actionstatus>
            </apex:panelgrid>    
        </apex:form>
    </apex:pageBlock>
</apex:component>

 

 

Controller code is

 

 

 

public class Poll 

 

{

public String UserVote{get;set;}

public String PollQuestion{get;set;}

public Poll__c [] AllPolls;

public List<SelectOption> PollOptions;

public Boolean FlagVoted{get;set;}

 

public List<SelectOption> getPollOptions()

{

PollOptions = new List<SelectOption>();

PollOptions.add(new Selectoption('YES', 'YES'));

PollOptions.add(new Selectoption('NO', 'NO'));

PollOptions.add(new Selectoption('NA', 'NA'));

return PollOptions;

}

 

public Poll()

{

UserVote = '';

AllPolls = [Select PollQuestion__c, DisplayDate__c, Active__c, Id From Poll__c Where Active__c=true and DisplayDate__c=TODAY ];

PollQuestion= AllPolls[0].PollQuestion__c;

}

 

public Pagereference SubmitVote()

{

try

{

FlagVoted = true;

}

catch(Exception ex)

{

ApexPages.addMessages(ex);

}

return null;

}

 

}

 

 

 

 

amitashtekaramitashtekar

Though I haven't added any code to the action method still the page is redirected to the insufficient error page.

Could you please help me.

joshbirkjoshbirk

One possibility: in the code you've got there, you would get an error/insufficient privs if there were no valid polls returned for your query.  Instead of:

 

AllPolls = [Select PollQuestion__c, DisplayDate__c, Active__c, Id From Poll__c Where Active__c=true and DisplayDate__c=TODAY ];

PollQuestion= AllPolls[0].PollQuestion__c;

 

You might try:

AllPolls = [Select PollQuestion__c, DisplayDate__c, Active__c, Id From Poll__c Where Active__c=true and DisplayDate__c=TODAY ];

if(AllPolls.size() > 0) {PollQuestion= AllPolls[0].PollQuestion__c;}

else { PollQuestion = '';}

amitashtekaramitashtekar

Thanks joshbirk,

The insufficient previledges is not shown at the time of loading the page.

But it is redirected to that page when I select the radio option on it.

I have provided actions support to it.

Code which is written under action fuctionn gets executed successfully but the page gets redirected to the error page showing error.

 

Even if I donot write a single line within action function still the page is redirected to the error page.

 

Another one thing that I would like to share with you that It is not  assured that the page will get redirected to the error page. Some times it works fine.

 

Could you please guide me on this.

DaveLDaveL

For future readers so you avoid the same silly mistake I made.  I was getting this same issue.  I could navigate to the page and display it, but any action (rerender, even a commandbutton submit) would cause the Insuficient Privilege error.

 

The problem was that I created this new page via Eclipse (force.com ide) and of course the PAGE SECURITY was set by default to my sysadmin profile only. AFAIK there is no way to affect that via the ide.  I just had to jump onto SFDC proper, go to Develop | Pages and find my page, click Security and add the needed (portal user) profiles.

 

The interesting thing is that SFDC doesn't throw this error on the first render of the page (which I got to via the "PageReference P = new PageReference... " syntax in a controller).....only on the first attempt to interact with it, which includes attempts at ajax rerender calls.  Which is why I chased my tail for a 1/2 day.

This was selected as the best answer
amitashtekaramitashtekar

Thanks for the sharing, Davel.

 

KevinBrKevinBr

Hopefully this might help some others:

 

I came across this also when I had a visual page with a lower API rev (15.0) due to editing via SF UI vs. Force.IDE.

The controller I was using was set to API 25.0 for the new Field Sets support.

When I changed the API on the page to version 20.0 it worked.

 

manjunath kademanimanjunath kademani
thanks mate u saved my day :)