You need to sign in to do that
Don't have an account?
Authorization Required Error when a VF form is submitted using a custom button
Hi,
I have created a Extended controller to documents.This VF page needs to be hosted on a site.
I have checked with all the ground rules to be followed to host the site and it is all done.
my site is :: http://sushumna-developer-edition.ap1.force.com/ApplicationForm
I am facing the following issues :
1.)When i fill in the form and submit the form(clicking a custom button) i get the error as:
Authorization Required
You must first log in or register before accessing this page.
If you have forgotten your password, click Forgot Password to reset it.
2.) I have an image displayed on the VF page in the site (stored in static resources) i am unable to view it when i am accessing the site out of Salesforce i.e; when i am not logged in to my account.
Could any one help me dealing with the issue.....
Thanks in advance... :)
You have a validation rule on your object.
if you want to keep this validation rule then you need to catch this error and show it to the user.
All Answers
#1) did you use your own save action in your extension class to redirect user to a visualforce page after the save. Otherwise standard save action will try to take you to the standard page which you can not expose via sites.
#2) edit your static resource and set the cache control field as Public
Hi,
To resolve the isuue faced in Point No.2 I implemented the solution provided in post.
I have changed Static Resources cache control to public.
But that couldnot still solve my issue. The image is not being displayed when I open my site outside salesforce.
For the issue mentioned in Point No.1
I have used a custom save button and not the standard save button.
Please help me in resolving this issue.
Thanks.
I have exactly the same problem, did you find a solution? here is the code:
<apex:page sidebar="false" showheader="false" controller="RegisterWebinarsController"> <style> body { font-family: Arial Unicode MS; }</style> <apex:form id="webinarsForm"> <apex:outputText style="font-weight: bold;font-size:150%;" value="User Registration"/> <apex:pageMessages id="error" /> <apex:panelGrid columns="2" style="margin-top:1em;"> <apex:outputLabel value="First Name:" for="firstname" />; <apex:inputText id="firstname" value="{!lead.firstname}" /> <apex:outputLabel value="Last Name:" for="lastname" /> <apex:inputText id="lastname" value="{!lead.lastname}" /> <apex:outputLabel value="Email:" for="email" /> <apex:inputText id="email" value="{!lead.email}" /> </apex:panelGrid> <br /> <apex:commandButton value="Continue" action="{!goToConnectPro}"/> <br /> </apex:form> </apex:page>
And the standardController:
public with sharing class RegisterWebinarsController { Lead lead; public Lead getLead() { if(lead == null) lead = new Lead(); } public PageReference goToConnectPro() { createNewWebinar(); PageReference webinars = new PageReference('https://webinar.company.com'); return webinars; } public void createNewWebinar(){ System.debug(lead); lead.site_ID__c = 'ost'; lead.Company = 'NA'; insert lead; } }
The problem ocurred when inserting the new lead. I gave public permissions to the user to "read" and "create" leads but I am getting the same message:
Authorization Required
You must first log in or register before accessing this page.
If you have forgotten your password, click Forgot Password to reset it.
What else I can do?
please help!
Hi,
I changed the code to catch the exception:
public with sharing class RegisterWebinarsController { Lead lead; public Lead getLead() { if(lead == null) lead = new Lead(); } public PageReference goToConnectPro() { createNewWebinar(); PageReference webinars = new PageReference('https://webinar.company.com'); return webinars; } public void createNewWebinar(){ System.debug(lead); lead.site_ID__c = 'ost'; lead.Company = 'NA'; try{ insert lead; }catch(Exception e){ System.debug('System exception ' + e); } } }
This is what I saw in the error logs:
System exception: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, You cannot create a demo account - please select a different prospect source.: []
How can I solve this problem?
You have a validation rule on your object.
if you want to keep this validation rule then you need to catch this error and show it to the user.