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
Angel Montiel 6Angel Montiel 6 

Site is giving me an Authorization Required error

Hi everyone:

I created a Visualforce page that has a form within, and when I tested it worked fine. It let me create the records I wanted in the custom object I prevously created "Pedidos__c"; but when I assigned to a Site I created in my Developer Edition Org, it just won't let me create the records when I push the save button. I already checked that all permissions are given to the guest user, and I read some forums about the Authorization Required error, but nothing seems to help me.

Here's the code:
 
<apex:page standardController="Pedido__c">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:inputField value="{!Pedido__c.Name}"/>
                <apex:inputField value="{!Pedido__c.Descripci_n__c}"/>
                <apex:inputField value="{!Pedido__c.Fabricante__c}"/>
                <apex:inputField value="{!Pedido__c.Presentaci_n__c}"/>
                <apex:inputField value="{!Pedido__c.Cantidad__c}"/>
                <apex:commandButton action="{! save}" value="Save!"/>
            </apex:pageBlockSection>
		</apex:pageBlock>
        <apex:pageMessages />
    </apex:form>
</apex:page>

And here´s the site URL: http://pedidos-developer-edition.na30.force.com/pedidos/

Thank you very much.
Best Answer chosen by Angel Montiel 6
SalesFORCE_enFORCErSalesFORCE_enFORCEr
Please make sure all the access (Object, FLS, Page) has been enabled for the guest profile. 
Also, what happens on click of Save? Are you redirecting to some success page or something becuse it is creating the records successfully. I just created one with Id a0I36000004P3OK

All Answers

SalesFORCE_enFORCErSalesFORCE_enFORCEr
Try to add that site guest user in debug logs and see if you are getting any error on click of Save.
Angel Montiel 6Angel Montiel 6
There you go @Shalabh_enFORCEr:

User-added image
 
User	Pedidos Site Guest User	Date	8/24/2016 2:44:38 PM VET
Status	Success	Application	Browser
Request Type	Application	Operation	/apex/Unauthorized
Duration (ms)	86	Log Size (bytes)	1,126
Log	
37.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
19:14:37.0 (673844)|USER_INFO|[EXTERNAL]|00536000002voZh|pedidos@pedidos-developer-edition.na30.force.com|Greenwich Mean Time|GMTZ
19:14:37.0 (723658)|EXECUTION_STARTED
19:14:37.0 (732408)|CODE_UNIT_STARTED|[EXTERNAL]|06636000006NdZ9|VF: /apex/Unauthorized
19:14:37.65 (65926086)|CUMULATIVE_LIMIT_USAGE
19:14:37.65 (65926086)|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 0 out of 100
  Number of query rows: 0 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Maximum CPU time: 0 out of 10000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 100
  Number of Email Invocations: 0 out of 10
  Number of future calls: 0 out of 50
  Number of queueable jobs added to the queue: 0 out of 50
  Number of Mobile Apex push calls: 0 out of 10

19:14:37.65 (65926086)|CUMULATIVE_LIMIT_USAGE_END

19:14:37.0 (65983540)|CODE_UNIT_FINISHED|VF: /apex/Unauthorized
19:14:37.0 (67408424)|EXECUTION_FINISHED

 
JeffreyStevensJeffreyStevens
Add access to the page and the controller to the guest user profile. 
SalesFORCE_enFORCErSalesFORCE_enFORCEr
Please make sure all the access (Object, FLS, Page) has been enabled for the guest profile. 
Also, what happens on click of Save? Are you redirecting to some success page or something becuse it is creating the records successfully. I just created one with Id a0I36000004P3OK
This was selected as the best answer
Angel Montiel 6Angel Montiel 6
Hi @Shalabh_enFORCEr. You are the man! You were right! Indeed, the records where being created. What happened is that I'm using the standard save button, and the page was redirecting to my org, and of course, guest users don't hace acces to my org. I need to create another Visualforce page with something like "Thank you for your response" or something.

Thanks again.