My request is to update the account field based on opportunity both has same fields name i.e segment1 which is multi select pick list values an account has multiple opp right. when i update the opp1 for segment1 its effetcing on account but when i update the opp2 its got refreshing and not adding the new one. i has to add both opp1 and opp2 on account and also if the same value is updated it should not be repeated.
I have tried. with my code if any ideas plz suggest me
trigger Opptyclosedwon on Opportunity (after update) {
list<account> aa= new list<account>();
for(opportunity c:trigger.new)
{
if(c.stagename=='closed won')
{
account a=[select marketsegment1__c,marketsegment2__c,marketsegment3__c from account where id=:c.accountid limit 1];
a.marketsegment1__c=c.marketsegment1__c;
a.marketsegment2__c=c.marketsegment2__c;
a.marketsegment3__c=c.marketsegment3__c;
aa.add(a);
}
}
update aa;
}