You need to sign in to do that
Don't have an account?
Paulo Perez
Arithmetic expressions must use numeric arguments
Dear
I need assistane. I dont know more what i can do, show me "Arithmetic expressions must use numeric arguments at line 13 column 29"
public class FrequenciaCompra{
public static void Frequencia(Account[] Conta) {
for (Account b :Conta){
AggregateResult[] opp =
[SELECT accountid,count(CloseDate) n
FROM Opportunity
WHERE
CloseDate>=:b.Primeira_Oportunidade__c and
CloseDate<=:b.Ultima_Oportunidade__c and
accountid=:b.id
group by accountid] ;
date startDate=b.Ultima_Oportunidade__c;
b.Frequencia__C=startDate.daysBetween(b.Primeira_Oportunidade__c)/opp[0].get('n');
b.update;
}
}
}
I need assistane. I dont know more what i can do, show me "Arithmetic expressions must use numeric arguments at line 13 column 29"
public class FrequenciaCompra{
public static void Frequencia(Account[] Conta) {
for (Account b :Conta){
AggregateResult[] opp =
[SELECT accountid,count(CloseDate) n
FROM Opportunity
WHERE
CloseDate>=:b.Primeira_Oportunidade__c and
CloseDate<=:b.Ultima_Oportunidade__c and
accountid=:b.id
group by accountid] ;
date startDate=b.Ultima_Oportunidade__c;
b.Frequencia__C=startDate.daysBetween(b.Primeira_Oportunidade__c)/opp[0].get('n');
b.update;
}
}
}
Try to replace your line with this below line and check..
b.Frequencia__C=(startDate.daysBetween(b.Primeira_Oportunidade__c))/opp[0].get('n');
:\ still does not work
b.Frequencia__C=Integer.valueof(startDate.daysBetween(b.Primeira_Oportunidade__c))/Integer.value(opp[0].get('n'));
public class FrequenciaCompra{
public static void Frequencia(Account[] Conta) {
for (Account b :Conta){
AggregateResult[] opp =
[SELECT accountid,count(CloseDate) n
FROM Opportunity
WHERE
CloseDate>=:b.Primeira_Oportunidade__c and
CloseDate<=:b.Ultima_Oportunidade__c and
accountid=:b.id
group by accountid] ;
date startDate=b.Ultima_Oportunidade__c;
b.Frequencia__C=Integer.valueof(startDate.daysBetween(b.Primeira_Oportunidade__c))/Integer.value(opp[0].get('n'));
update b;
}
}
}
I found my mystake, now it works!! :)
public class FrequenciaCompra{
public static void Frequencia(Account[] Conta) {
List<Account> accsToUpdate = new List<Account>();
for (Account b :Conta){
AggregateResult[] opp =
[SELECT accountid,count(CloseDate) n
FROM Opportunity
WHERE
CloseDate>=:b.Primeira_Oportunidade__c and
CloseDate<=:b.Ultima_Oportunidade__c and
accountid=:b.id
group by accountid] ;
date startDate=b.Ultima_Oportunidade__c;
b.Frequencia__C=startDate.daysBetween(b.Primeira_Oportunidade__c)/(integer)opp[0].get('n');
accsToUpdate.add(b);}
update accsToUpdate; }
}