3

I created a with sharing class and also have with sharing wrapper class. But When I try to run my Vf Page I am getting error

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.

I am am loged as admin for this org. Then what this kind of Insufficient Privileges issue is coming. I am adding my code over here please tell me is I am doing anything wrong in my code.

VF Page

    <apex:repeat value="{!wcls}" var="sobj">
        {!sobj}   
    </apex:repeat>

controller :

public with sharing class survey_ResultV2Ctrl{

public Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
//public Map<Schema.SObjectType, List<Schema.SObjectField>> sObjectFieldMap {get; set;}
public List<Schema.SObjectField> sObjectFieldLst = new List<Schema.SObjectField>();
public List<wrapperClass> wcls {get; set;}
public set<Schema.SObjectType> objNameSet =  new set<Schema.SObjectType>();

public survey_ResultV2Ctrl(){
    //sObjectFieldMap = new  Map<Schema.SObjectType, List<Schema.SObjectField>>();
    wcls =  new List<wrapperClass>();
    survey_ResultDisplay();
}

public void survey_ResultDisplay(){

    for(Filter_Field_Set__c ffs : [SELECT Name, Field_Set_Category__c, Object_Fields__c, Object_Fields_Name__c FROM Filter_Field_Set__c Where Field_Set_Category__c = 'a0F9000000R5FZr']){
        system.debug('All the result from Filter Field Set object ' + ffs.Name);
        system.debug('Schema Map contains Key as object name ' + schemaMap.containsKey(ffs.Name));
        Map <String, Schema.SObjectField> fieldMap = schemaMap.get(ffs.Name).getDescribe().fields.getMap();
        if(schemaMap.containsKey(ffs.Name)){
            system.debug('Schema object Values ' + schemaMap.get(ffs.Name));
            system.debug('All the fields related to Schema object ' + fieldMap.get(ffs.Object_Fields_Name__c));

            if(objNameSet.contains(schemaMap.get(ffs.Name))){
                sObjectFieldLst.add(fieldMap.get(ffs.Object_Fields_Name__c));
                //sObjectFieldMap.put(schemaMap.get(ffs.Name), sObjectFieldLst.clone());
                objNameSet.add(schemaMap.get(ffs.Name));
                wcls.add(new wrapperClass(schemaMap.get(ffs.Name), sObjectFieldLst.clone()));
                sObjectFieldLst.clear();
            }
            else{
                sObjectFieldLst.add(fieldMap.get(ffs.Object_Fields_Name__c));
                //sObjectFieldMap.put(schemaMap.get(ffs.Name), sObjectFieldLst.clone());
                wcls.add(new wrapperClass(schemaMap.get(ffs.Name), sObjectFieldLst.clone()));
                objNameSet.add(schemaMap.get(ffs.Name));
            }
        }

    }

    system.debug('The wapper class after loop ' + wcls);

}


public with sharing class wrapperClass{

    public list<Schema.SObjectField> fieldname {get; set;}
    public Schema.SObjectType objectName {get; set;}

    public wrapperClass(Schema.SObjectType objectName, list<Schema.SObjectField> fieldname){
        // objectName = new Schema.SObjectType();
        // fieldname = list<Schema.SObjectField>();
    }
}
}

Please give my any idea over this issue.

  • 5
    you (or your sys admin) need too add this vf page to your profile. another thing to check is a permission set that is possibly assigned to your user account. – Sergej Utko Sep 27 '14 at 9:44
  • @anu try to keep version of your pages,componenet and controller same version. I faced such use cases may times becuase of version. hope it will work for you :) – Ankuli Sep 29 '14 at 6:02
1

Few things to check:

  1. Identify all objects which are used in VF controller. Make sure you have modify all permission for objects.
  2. Check for all field permissions for objects used in Visualforce controller. Make all fields visible by editing field level permission. May be you have moved new objects using changeset. Field level security will prevent access to those new field.
  3. On profile make sure you have added controller in Apex class list.
-1

enter image description here

provide security for profile to access vf page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.