Example

List<Contact> newConList = new List<Contact>();

List<Contact> conList = [select firstname, lastname from contact];

Integer i = 1;

for(Contact cc : conList)

{

String s = cc.name;

if(s.conatins(‘Contact’))

{

cc.phone = ‘1234’;

newConList.add(cc);

}

else

{

Contact c1 = new Contact(lastname=’Contact’+i);

I++;

newConList.add(cc);

}

}

upsert newconList;

Our Recent Blog

Share This Post