October 21, 2013

How to populate field values in Standard Page Layout in Salesforce?


The relationship between Member and Blog objects is Lookup. Member is parent and Blog is child.

When "New Blog" button is clicked from Blog related list in Member Detail page, the Blog owner field in Blog record should be auto populated from Member Name.

See the below steps for solution

To find object URL:

To find the Id of the inputText:

Visualforce page:

<apex:page standardController="Blog__c" extensions="NewBlogOverriddenExt" action="{!onLoad}>


Apex Class:

public class NewBlogOverriddenExt {
    Blog__c blog = new Blog__c();
    Id memberId;
    public NewBlogOverriddenExt(ApexPages.StandardController controller) {
        blog = (Blog__c)controller.getRecord();
        memberId = blog.Member__c;
    public PageReference onLoad() {
        Member__c member = [SELECT Name FROM Member__c WHERE ID = : memberId];
        PageReference pg = new PageReference('/a03/e?');
        pg.getParameters().put('nooverride','1');// Important to avoid recursion
        return pg;

Override New button in Blog object:



1 comment:

  1. Hi Magulan ,Good Post.My requirement is the layout should auto populate all the line items with part numbers(Product code )from quote line items.how to get this.any hint plz