You need to sign in to do that
Don't have an account?
Bill Button
Count number of records returned
Hi,
How to check number of records returned. Currentrly when I try to make "if (AssignmentRegionOnly = 1) {" it errors with condition expression must be of type Boolean.
for (Lead a : Trigger.new) {
integer AssignmentRegionOnly = [select Count() from Assignment__c where Country__c = :a.Country and State_County__c = :a.State];
if (AssignmentRegionOnly > 0) {
Assignment__c AssignThis = [select Area_Account_Manager__c,Reseller__c from Assignment__c where Country__c = :a.Country and State_County__c = :a.State];
SendEmail = 1;
a.OwnerId = AssignThis.Area_Account_Manager__c;
if (AssignThis.Reseller__c != null ) {
a.Reseller__C = AssignThis.Reseller__C;
SendToReseller = 1;
}
}
else {
integer AssignmentRules = [select Count() from Assignment__c where Country__c = :a.Country];
if (AssignmentRules > 0) {
Assignment__c AssignThis = [select Area_Account_Manager__c,Reseller__c from Assignment__c where Country__c = :a.Country];
a.OwnerId = AssignThis.Area_Account_Manager__c;
SendEmail = 1;
if (AssignThis.Reseller__c != null ) {
a.Reseller__C = AssignThis.Reseller__C;
SendToReseller = 1;
}
}
else {
integer AssignmentRegionOnly = [select Count() from Assignment__c where Country__c = :a.Country and State_County__c = :a.State];
if (AssignmentRegionOnly > 0) {
Assignment__c AssignThis = [select Area_Account_Manager__c,Reseller__c from Assignment__c where Country__c = :a.Country and State_County__c = :a.State];
SendEmail = 1;
a.OwnerId = AssignThis.Area_Account_Manager__c;
if (AssignThis.Reseller__c != null ) {
a.Reseller__C = AssignThis.Reseller__C;
SendToReseller = 1;
}
}
else {
integer AssignmentRules = [select Count() from Assignment__c where Country__c = :a.Country];
if (AssignmentRules > 0) {
Assignment__c AssignThis = [select Area_Account_Manager__c,Reseller__c from Assignment__c where Country__c = :a.Country];
a.OwnerId = AssignThis.Area_Account_Manager__c;
SendEmail = 1;
if (AssignThis.Reseller__c != null ) {
a.Reseller__C = AssignThis.Reseller__C;
SendToReseller = 1;
}
}
else {
//
// No Match Found need to assign to Lead Queue
//
a.OwnerID = '00G20000000qGsmEAE';
SendEmail = 1;
SendToReseller = 0;
}
}
// No Match Found need to assign to Lead Queue
//
a.OwnerID = '00G20000000qGsmEAE';
SendEmail = 1;
SendToReseller = 0;
}
}
Thanks
Bill
note the extra = character
Hi Simon,
Thanks for the help, I have also just put a nice dent in the wall with my forehead for being dumb
Thanks
Bill