You need to sign in to do that
Don't have an account?
Abhishek_New
Initial term of field expression must be a concrete SObject: LIST<Account> at line 20 column 8
trigger UpdateContactNo on Contact (after insert) { list<Account> acc = new list<Account>();
for(Contact c:trigger.new)
{
list<Account> ac =[select id,No_of_Contacts__c from Account where id =: c.AccountId];
for(Account a : ac)
{
if (a.No_of_Contacts__c != null){
a.No_of_Contacts__c = a.No_of_Contacts__c+1;
acc.add(a);
}
else{
a.No_of_Contacts__c = 1;
acc.add(a);
}
}
}
try
{
if(!acc.isEmpty)
update acc;
}
catch(Exception e)
{
e.getMessage();
}
}
Error is coming in if (a.No_of_Contacts__c != null)line...
At line 3 where you're doing query change it to
List<Account> ac = new List<Account>();
ac = [QUERY];
and in try block you're not calling empty function. Change it to as mentioned below
try
{
if(!acc.isEmpty())
update acc;
}
All Answers
At line 3 where you're doing query change it to
List<Account> ac = new List<Account>();
ac = [QUERY];
and in try block you're not calling empty function. Change it to as mentioned below
try
{
if(!acc.isEmpty())
update acc;
}
It Worked..Thanks...