Activity Forums Salesforce® Discussions How to populate Child Field from a Parent field in Salesforce?

  • sushant

    January 27, 2017 at 2:14 pm

    Hi Vikas,

    Try this:

    trigger trigsetLastName on Contact (after insert,after update)
    Map<id,account> parentacc = new Map<id,account>();
    Set<id> listids = new Set<id>();

    for( contact childobj
    listids.add(childobj.accountid); // error in this line

    parentacc= new map<id,account> ([select id,Name ,(select id,LastName from contacts) from account where id in: listids]);

    for ( contact c
    account myacc = parentacc.get(c.accountid);
    Update parentacc.values();


Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos