You need to sign in to do that
Don't have an account?
harish reddy 50
Error: Compile Error: Illegal assignment from Integer to String
trigger avgtrigger on Contact (after insert,after update) {
LIST<id> ids=new LIST<id>();
integer value=0;
for(contact conn:trigger.new)
{
ids.add(conn.accountid);
}
LIST<account> acc=[select avgrating__c,(SELECT id,rating__c from contacts where rating__c!=null)from account];
LIST<account> acc1=new LIST<account>();
for(account acc2:acc)
{
for(contact con:acc.contact)
{
value=value+con.rating__c;
}
acc2.avgrating__c=value/acc2.contacts.size();//here its showing error
acc1.add(acc);
}
update acc1;
}
can anyone help me..
thanks in advance.
LIST<id> ids=new LIST<id>();
integer value=0;
for(contact conn:trigger.new)
{
ids.add(conn.accountid);
}
LIST<account> acc=[select avgrating__c,(SELECT id,rating__c from contacts where rating__c!=null)from account];
LIST<account> acc1=new LIST<account>();
for(account acc2:acc)
{
for(contact con:acc.contact)
{
value=value+con.rating__c;
}
acc2.avgrating__c=value/acc2.contacts.size();//here its showing error
acc1.add(acc);
}
update acc1;
}
can anyone help me..
thanks in advance.
Try to update your code like below
Let us know if this will help you