+ Start a Discussion

How to get the input from user without logging and save it in Force.com database?


    I created a fields in a visualforce page and when i enter all the fields and click on save button its saving the record and redirecting to proper records page.Now i want to make this page as public and without logging in salesforce user has to enter all the fields and the moment user clicks the save button it has to save the record and redirect to particular page.Now here i completed visualforce page to sites and got the output,but when i enter all the fields and click on save button its showing unauthorised access and you need to login with proper username and password.Can anyone pls tell how to make public and what to done on save action and page redirection.


Thanks in advance.



Message Edited by Coder on 07-17-2009 08:51 PM
I would use a custom controller instead of the standard controller in your scenario. In the custom controller, you can define your own "save" method. In that method, you can navigate the end-user to a different Force.com Site page or update the existing page with a status message, ect. The standard controller "save" action will automatically redirect the user to the newly created record.

Thank You for your replying...



May i know how to redirect the page in custom controller and can u post the code for custom controller save action and page redirection.


Here is a quick sample of a method that can be called by an action in your Visualforce page tied to this custom controller:



public class MyController { public Account account {get;set;} public PageReference save() { update account; PageReference pageRef = new PageReference('http://www.google.com'); return pageRef; } }


 Please see these helpful Visualforce links: Custom Controllers and PageReference Class