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
jucuzoglujucuzoglu 

Getting a permission error when trying to use Save method in Standard Controller

Everything seems to work fine until the controller DML Save function attempts to run from the Guest user. Here is a few relevant lines from the logs, the last line showing the insufficient privilages.

 

13:59:57.127 (127222000)|SYSTEM_METHOD_ENTRY|[15]|ApexPages.StandardController.save()
13:59:57.127 (127249000)|SYSTEM_MODE_ENTER|false
13:59:57.127 (127273000)|DML_BEGIN|[15]|Op:ControllerSave|Type:Partner_Position_Draft__c|Rows:1
13:59:57.155 (155907000)|VF_PAGE_MESSAGE|Insufficient Privileges

Things I think i have checked in the Site User profile

 

- Enabled Visibility for all fields

- Added the APEX extension class to the the Site User Profile

- Added the VisualForce page to the Site User Profile

- Have both Read and Edit privilages enabled for the Site User Profile

 

I don't have create privilages for the Site User for that profile but don't think that should be relevant.

 

I appriciate any hints provided as to the next thing I should be checking.

salesforce expertsalesforce expert

can you post the code snippet of the controller?

jucuzoglujucuzoglu

here is the controller extension code

 

public class ext_PartnerPositionProposal {

private Partner_Position_Draft__c PPD = new Partner_Position_Draft__c();

    public ext_PartnerPositionProposal(ApexPages.StandardController controller) {
        PPD = (Partner_Position_Draft__c)controller.getRecord();
    }
    
    public PageReference submit()
    {        
        // Change Stage
        PPD.Status__c = 'submitted';
        //Controller.save();
        ApexPages.StandardController controller = new ApexPages.StandardController(PPD);
        controller.save();
        //logic to save your data
        PageReference p = new PageReference('http://www.broadcenter.org/Updated.html');
        p.setRedirect(true);
        return p;            
    }
    
           static testMethod void test_ext_PartnerPositionProposal() {
                //Test converage for the myPage visualforce page
                
                PageReference pageRef = Page.PartnerPositionProposal;           
                Test.setCurrentPageReference(pageRef);
                
                // Verify that page fails without parameters 
            System.assertNotEquals('/apex/failure?error=noParam', pageRef.getUrl());
            
                Partner_Position_Draft__c myPPD = [Select Id,Status__c 
                From Partner_Position_Draft__c Limit 1];
                
                ApexPages.StandardController ppd = new ApexPages.standardController(myPPD);
                
                // create an instance of the controller
                
                ext_PartnerPositionProposal PPP  = new ext_PartnerPositionProposal(ppd);                
                PPP.submit();   
                
                }        
    
}

 

jucuzoglujucuzoglu

Ok more information that I think may impact the issue.

 

The custom object I am working on is a child of Opportunity which has some restrictions with respect to some account types (like Site users).

 

The big issue is you can only have Read/Create permissions. Even though I don't have any rollup summaries, I am wondering if Saving a record is somehow requiring edit permissions for the parent object (Opportunity) which are not possible for Site users.

 

Anyone know if I may be on the right track?

 

 This happens when the Standard Controller Save method is used on the Custom Object

SF Expert.ax1061SF Expert.ax1061

Try to run this page internally.. May be due to some other issue this could comming..

 

If it is working intrenally.. then go to site profile give access manually on all teh fields for this object.

 

After that it will work.

 

Let me know if it is not working

 

Thanks

 

techie.in.sf@gmail.com