• #15030
    Salesforce | PRANAV PRANAV #707

    How to use vf page of custom controller in sobject page?

    Hi All,

    How to use vf page of custom controller in sobject page?



    Salesforce | Saurabh Saurabh #251

    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
    myAccount.name = 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:


Viewing 2 posts - 1 through 2 (of 2 total)

Please to reply to this topic.


We're not around right now. But you can send us an email and we'll get back to you, asap.


About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2019 Forcetalks. All Right Reserved.

Log in with your credentials


Forgot your details?