So as the title states I am trying to populate a field from the premium object with data from fetchRates. I have code that works but it is not populating for some reason. Any assistance would be much appreciated.
I am wondering id the premium rate is actually gathering data
Trigger
trigger fetchAgeFactor on priceByAge__c (before insert, before update)
{
priceByAge__c[] age = Trigger.new;
fetchRates.ageRate(age);
}
Class
public class fetchRates {
//integer baseRate = 211.15;
public static void ageRate(priceByAge__c[] age)
{
string ageRate = NULL;
Premium_Rate__c[] rate;
for (priceByAge__c a :age){
ageRate = a.Name;
for (Premium_Rate__c main :rate){
if (main.Age_del__c.contains(ageRate)){
main.ageRate__c = a.Rate_Factor__c;
}
}
}
}
}
rate
variable is null and empty. 2. I would use maps for comparison rather than using two loops