Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.
error

We made a wrong turn. Try again.

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.
15 answers
  1. Feb 27, 2015, 2:14 PM
    Hello Friend,

    You can do it without sharing class/permission set with Account read, create, edit permission

    try this  without sharing class:

     

    public without sharing class AccountController {

    public Account account{get; set;}

    public AccountController(){

    account = new Account();

    }

    public void save(){

    upsert account;

    }

    }

     

    <apex:page controller="AccountController">

    <apex:form>

    <apex:pageBlock title="My Content" mode="edit">

    <apex:pageBlockButtons>

    <apex:commandButton action="{!save}" value="Save"/>

    </apex:pageBlockButtons>

    <apex:pageBlockSection title="My Content Section" columns="2">

    <apex:inputField value="{!account.name}"/>

    <apex:inputField value="{!account.site}"/>

    <apex:inputField value="{!account.type}"/>

    <apex:inputField value="{!account.accountNumber}"/>

    </apex:pageBlockSection>

    </apex:pageBlock>

    </apex:form>

    </apex:page>

    If this answers your question then hit Like and mark it as solution!

     
  2. Dec 21, 2015, 6:17 PM

    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.

    Visualforce code:

    <apex:page standardController="Player__c" extensions="all_player">

    <apex:form >

    <apex:pageBlock title="Player Information">

    <apex:pageBlockSection >

    <apex:inputField value="{!Player__c.Name}"/>

    <apex:inputField value="{!Player__c.Club_Captain__c}"/>

    <apex:inputField value="{!Player__c.Jersey_Number__c}"/>

    <apex:inputField value="{!Player__c.team1__c}"/>

    </apex:pageBlockSection>

    <apex:pageBlockButtons location="top">

    <apex:commandButton value="Save" action="{!save}"/>

    <apex:commandButton value="Cancel" action="{!cancel}"/>

    </apex:pageBlockButtons>

    </apex:pageBlock>

    </apex:form>

    </apex:page>

    Class code:

    public class all_player

    {

    public Player__c t1{get;set;}

    public all_player(ApexPages.StandardController controller)

    {

    t1= new Player__c();

    }

    public PageReference save()

    {

    insert t1;

    PageReference p=new PageReference('/a0T/o');

    return p;

    }

    }

0/9000