You need to sign in to do that
Don't have an account?
prasad1.3969574005596787E12
Initial term of field expression must be a concrete SObject: LIST
I am trying to update an account from contact field as i had tried my code having this error
"Initial term of field expression must be a concrete SObject: LIST"
"Initial term of field expression must be a concrete SObject: LIST"
List<Account> acc = new List<Account>(); List<Contact> con = new List<Contact>(); Set<Id> setid = new Set<Id>(); Contact c = new contact(); Account a = new Account(); con = [SELECT name,Accountid FROM Contact WHERE Lastname='Rahul']; setid.add(con.id); acc = [SELECT name FROM Account WHERE id in: setid]; acc.name = 'Naveen Rahul'; update acc;
acc is a list of accounts but you are trying to set the list variable name as if it is an individual record.
Try doing
acc[0].name = 'Naveen Rahul';
or use a for loop to loop through the account results and declare each account name as 'Naveen Rahul'
Hope this helps !!
All Answers
acc is a list of accounts but you are trying to set the list variable name as if it is an individual record.
Try doing
acc[0].name = 'Naveen Rahul';
or use a for loop to loop through the account results and declare each account name as 'Naveen Rahul'
Hope this helps !!
setid.add(con.id);
acc = [SELECT id,name FROM Account where id in: setid];
for(integer i=0; i<setid.size(); i++){
acc[i].name = 'Naveen Rahul';
}
update acc;
Note : Never use SOQL statements within for loop. Let me know if you have any further issues.
Thankyou,
I got the solution.......!
ThankQ for all.....
:-)