updating data of one list by getting value from another list we will need a map for this case(2nd ''for loop'')
public void test(list<Contact> triggerNew)
{
Set<ID> stID=new Set<ID>();
if(triggerNew.size()>0 && triggerNew!=null)
{
for(Contact obj:triggerNew)
{
stID.add(obj.accountid);
}
}
List<Account> lstAccount=new List<Account>();
Map<id,String> mp=new Map<id,string>();
lstAccount=[Select id,name from Account where id in:stID];
for(Account ob:lstAccount)
{
}
for(Contact objj:TriggerNew)
{
objj.Title=mp.get(objj.accountid)+'Krrish';
}
}
No comments:
Post a Comment