Activity Forums Salesforce® Discussions How to write a Salesforce trigger for below given scenario?

  • Raghav Chaturvedi

    Member
    July 13, 2017 at 2:40 pm

    trigger concatinat on Contact (after insert,after update)
    {
    List accList = new List();
    set S = new Set();
    for(contact con : Trigger.new)
    {
    S.add(con.accountid);
    }
    Map mv = new Map([SELECT id,name
    FROM account WHERE Id IN : S]);

    for(contact cont : Trigger.new)
    {
    Account acct = new Account();
    acct.id = mv.get(cont.accountid).id;
    acct.name = mv.get(cont.accountid).name + '-' +cont.lastname;
    accList.add(acct);

    }
    update accList;
    }

  • shariq

    Member
    July 14, 2017 at 12:39 pm

    Hi Raghav,

    Can you do this without using map.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos