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
Charlie CoxCharlie Cox 

Insufficient Privileges with <apex:actionFunction>

I am the System Admin for our instance. I am currently developing a visualforce page. The System Admin profile has access to the page and controller.

However when I call my action function I get a "Insufficient Privileges" error message.
User-added image

I investigated further to see that I was getting an Internal Server Error.
User-added image

I have stripped functionality in the apex method the actionFunction calls until it does nothing. See Below:
 

public class UtilApplication {

    public List<List<SelectOption>> display {get;set;}
    public String assigned {get;set;}
    Map <String, Schema.SObjectType> objs {get;set;}
    
    public UtilApplication() {
        
        display = new List<List<SelectOption>>();
        
        objs = Schema.getGlobalDescribe();
        
        List<SelectOption> init_opts = new List<SelectOption>();
        
        // Value | Label
        init_opts.add(new SelectOption('Student_Application__c','Student Application'));
        init_opts.add(new SelectOption('Contact','Contact'));
        
        display.add(init_opts);
        
        System.debug('In constructor');

    }
    
    // method in question
    public void add_object() {
        System.debug('In here');
    }
}
The Visualforce looks like this:
 
<apex:page showHeader="false" sidebar="false" controller="UtilApplication">
    <head>
		<script>
        	function callJS() {
            	console.log("In this");
                select_section();   
            }
        </script>
    </head>  
    <body>
        <apex:form>
            <apex:outputPanel id="configure">
                <apex:outputPanel>
                    <apex:pageBlock title="Select Section">
                        <apex:actionFunction name="select_section" action="{!add_object}" reRender="configure"/>
                            <apex:selectList multiselect="false" value="{!assigned}" size="1" onchange="callJS()">
                                <apex:selectOptions value="{!display[0]}"/>
                            </apex:selectList>
                    </apex:pageBlock>
                </apex:outputPanel>
            </apex:outputPanel>
        </apex:form>
    </body>
</apex:page>

I have used actionFunctions like this before so I am not sure what the issue is.

Any input would be great.

Thanks!

 

Best Answer chosen by Charlie Cox
Charlie CoxCharlie Cox
Looks like the problem is still there. I solved it by removing the objs Map. It seems strange that I can use it in the constructor but not the method.

All Answers

Gaurav_SrivastavaGaurav_Srivastava
Hi Charlie,

Try below code and let me know if issue is still there.
<apex:page showHeader="false" sidebar="false" controller="UtilApplication">
	<script>
		function callJS() {
			console.log("In this");
			select_section();   
		}
	</script>
	<apex:form>
		<apex:actionFunction id="select_sectionStatus" name="select_section" action="{!add_object}" reRender="pageBlockId,pageMsgs"/>
			<apex:pageBlock title="Select Section" id="pageBlockId">
				<apex:outputPanel id="pageMsgs">
					<apex:pageMessages ></apex:pageMessages>
				</apex:outputPanel>
				<apex:selectList multiselect="false" value="{!assigned}" size="1" onchange="callJS()">
					<apex:selectOptions value="{!display[0]}"/>
				</apex:selectList>
			</apex:pageBlock>
	</apex:form>
</apex:page>
Thanks,
Gaurav
Charlie CoxCharlie Cox
Looks like the problem is still there. I solved it by removing the objs Map. It seems strange that I can use it in the constructor but not the method.
This was selected as the best answer