You need to sign in to do that
Don't have an account?
Authorization Required error while inserting custom objects from website
I have created custom object called 'students'. I have developed the visualforce page and controller class, which accepts student details and creates a new record. It is working properly when executed from 'https://c.ap1.visual.force.com/apex/StudentForm8'.. I.e. within the account.
When I try to load this VF page from my website, it is giving me error like
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.
I checked the following things :-
1- custom object status is set as "Deployed"
2- the site public access settings has Read, create and edit permission on this custom object
3- the Site public access settings Field Level security are set as "Visible" for the fields that are displaying on this page
4- Page is associated with my site
Here I am attaching my code
Visualforce page "StudentForm8"
<apex:page controller="MyController8" tabStyle="Account" > <apex:form > <apex:pageBlock mode="edit"> <apex:pageMessages /> <apex:pageBlockSection > <apex:inputField value="{!Details.name}"/> <apex:inputField value="{!Details.Branch__c}"/> <apex:inputField value="{!Details.Subjects__c}"/> <apex:inputField value="{!Details.Aggregate__c}"/> </apex:pageBlockSection> <apex:pageBlockButtons location="bottom"> <apex:commandButton value="Save" action="{!save}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
Controller code named "MyController8"
public class MyController8 { public Student__c stud { get; set; } public MyController8() { stud = new Student__c(); } public Student__c getDetails() { return stud; } public PageReference save() { try { insert(stud); } catch(System.DMLException e) { ApexPages.addMessages(e); return null; } PageReference pageRef = new PageReference('http://myappmbb-developer-edition.ap1.force.com/RegiSuccess'); return pageRef; } }
After record creation page wasredirecting to system page showing detail new record. I thought it is creating problem as system page can't be available on website. So I redirected it to fix url "http://myappmbb-developer-edition.ap1.force.com/RegiSuccess".. RegiSuccess page is visible from my website.
In spite of all these things page is not accessible from website.
What would be the possible error?
Any kind of help would be greatly appreciated.
Did you check the status of the site if it is active. If yes then try to run the site by clicking on the site URL eg.
Setup->App Setup->Develop->Sites->under site URL click on the URL and see if it is working.
Also in your VF page security do add your Customer Portal profile.
Thanks
Utsav
[Do mark this answer as solution if it works for you and give a kudos.]
With REFRESH, your newly created record will be displayed, you need not change the listView ie. All.
next time, after inserting the record, try REFRESH button, it may take some time, but it will refresh.
And, If you want to use the TabStyle of Account, go to-->publicAccess settings, check Read checkbox against Accounts.