You need to sign in to do that
Don't have an account?
mritz
How to save record in Account Object Using VisualForce Page
I want to create a VisualFroce page having input fields in it. I want this page to enable Guest User to enter new record in Account Object( or any other Object).
I want headStart on how to write code for Save/Search/Edit/Delete Functions on a visulaForce page.
(Assume that i have created required input fields on visualFroce Page)
I can do this using Flow but i want to acheive this using VisualForce Page.
Even a link to similar solved question would do.
PS: Salesforce is new to me.
You can do it without sharing class/permission set with Account read, create, edit permission
try this without sharing class:
If this answers your question then hit Like and mark it as solution!
All Answers
Try this : If this answers your question then hit Like and mark it as solution!
Will it work without user account, i mean can a guest user save records using this code embedded in "site". or do i need to tweak user permissions somewhere.
You can do it without sharing class/permission set with Account read, create, edit permission
try this without sharing class:
If this answers your question then hit Like and mark it as solution!
Yes we can provide the Public Access settings to profile for guest user for the site, Account (Read & Create only).
If this answers your question then hit Like and mark it as solution!
Yes. From the question I though m ritzi 9 is talking about Force.com site. If not for site then the code you have written would perfectly work without bothering about sharing rules and user permissions using the custom controller as they operate in system mode and ignores the user permission and sharing rules etc.
m ritzi 9 - Please clarify if you are looking to update/insert/delete from Force.com public site or in the salesforce only?
I am talking about Force.com Sites.
I want that a person without having login access to salesforce can create new records in Account Object.
OK. Thanks for clarifying. As I said YES this is possible that "a person without having login access to salesforce can create new records in Account Object." . First write your visualforce page and if required controller for that and then in the Public Access Setting of the Site just give the Read and Create permission for the guest user license.
How to i enable users to edit and delete there details from Account Object again without "loggin in".
How can i acheive this using visual force page.
See you can save, edit, create records through salesforce site but like you want a user to see only some specific Account records like of his/her own then you have to write the Visualforce accordingly. Like in the Controller class you can use Userinfo.getUserId() to get the Id of the currently logged in user and based upon that you can expose records. So that logic you have to figure out how do you want.
The baseline is, for Guest Profile first you need to give the proper Object level permissions to let the user see/edit etc the records and then in the VF page and Controller that you create there you have to figure out which records to show and how etc.
Let us know if you need more help.
I tried this code and it is working for Standard Objects but it is not working for Custom Objects. In this code the record is getting inserted but it is inserting with some random ID as name such as a0T28000000TsyE,etc. Can anyone provide me the solution for Custom Objects.