function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Hi everyone
Can we update any of the field except ‘id ’more than 2 records simultaneously from single list. Is it possible?
Hi,
Try the below code snippet as reference:
list<sobject> sobjecttest=new list<sobject>();
list<account> acc=[select id ,name from account limit 1000];
if(acc.size()>0)
{
acc[0].name=acc[0].name+'test';
sobjecttest.add(acc[0]);
}
list<contact>con=[select firstname from contact limit 1000];
if(con.size()>0)
con[0].firstname=con[0].firstname+'test';
sobjecttest.add(con[0]);
update sobjecttest;
for(integer i=0;i< acc.size();i++)
acc[i].name=acc[i].name+' test '+string.valueof(i);
update acc;
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi ankit
Thanks but i want to update more than 2 records which has different types of object and update from single list.
Hi,
Try the below code snippet as reference:
list<sobject> sobjecttest=new list<sobject>();
list<account> acc=[select id ,name from account limit 1000];
if(acc.size()>0)
{
acc[0].name=acc[0].name+'test';
sobjecttest.add(acc[0]);
}
list<contact>con=[select firstname from contact limit 1000];
if(con.size()>0)
{
con[0].firstname=con[0].firstname+'test';
sobjecttest.add(con[0]);
}
update sobjecttest;
All Answers
Hi,
Try the below code snippet as reference:
list<account> acc=[select id ,name from account limit 1000];
for(integer i=0;i< acc.size();i++)
{
acc[i].name=acc[i].name+' test '+string.valueof(i);
}
update acc;
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi ankit
Thanks but i want to update more than 2 records which has different types of object and update from single list.
Hi,
Try the below code snippet as reference:
list<sobject> sobjecttest=new list<sobject>();
list<account> acc=[select id ,name from account limit 1000];
if(acc.size()>0)
{
acc[0].name=acc[0].name+'test';
sobjecttest.add(acc[0]);
}
list<contact>con=[select firstname from contact limit 1000];
if(con.size()>0)
{
con[0].firstname=con[0].firstname+'test';
sobjecttest.add(con[0]);
}
update sobjecttest;