Activity Forums Salesforce® Discussions How can i pass Lookup in salesforce Apex?

  • Manpreet

    Member
    April 4, 2017 at 1:58 pm

    Hi suraj,

    I have used "ob" to show the new record. Therefore it should be inserted in the Save function.

    ___________________________________________________________________________

     

    public class Test {

    public Test ob {get;set;}

    public Test(ApexPages.StandardController controller) {
    Contact c = (Contact)controller.getRecord();
    ob = new Test();
    ob.Contact__c = c.Id;
    }

    public PageReference save() {
    insert ob;
    PageReference pg = new ApexPages.StandardController(ob).view();
    pg.setRedirect(true);
    return pg;
    }
    }

    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos