Activity Forums Salesforce® Discussions How to use vf page of custom controller in sobject page?

  • Saurabh

    March 24, 2017 at 7:38 am

    Hi Pranav,

    If i am not wrong i think you want to create an sobject page replica by using custom controller.

    you can try this:

    #vf  page for making sobject account with field accountname:

    <apex:page controller=”myController” >
    <apex:form >
    <apex:pageBlock title=”My Content” mode=”edit”>
    <apex:pageBlockButtons >
    <apex:commandButton action=”{!save}” value=”Save”/>
    <apex:pageBlockSection title=”My Content Section”
    <apex:outputLabel for=”aName”>Account Name:</
    <apex:inputText value=”{!accountName}”/>

    #And the controller class for this:

    public with sharing class myController {
    private final Id accountId&nbsp;;
    public final String accountName {get; set; }

    public myController() {
    Account account = [select Id, Name from Account where id
    accountId = account.Id&nbsp;;
    accountName = account.Name&nbsp;;

    public PageReference save() {
    Account myAccount = [select name from Account where id
    =&nbsp;:accountId]; = accountName&nbsp;;
    update myAccount;
    return null;

    Similarly you can add more fields as you wanted by adding components in vf page and creating functions in controller class.

    Hoping this is the solution for you question:


Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos