You need to sign in to do that
Don't have an account?
sunil2018
error in looping
i am writing a code that iterate and add the first rate it finds, then replace it with any record that’s Current in Ag or Current in LA or Ag. So if a pending row happens to be before the Current in LA row (and there is no Current in Ag record), the pending rate will be sent to the service instead of the Current in LA row.
Logic is missing to specifically look for "Current in Loan Accounting" row next if CurrentinAg is not there. please provide any suggestions on it.
Map<Id, Rate_Stream__c> ratesForTakedown = new Map<Id, Rate_Stream__c>();
for(Rate_Stream__c rateRecord : rates){
if(ratesForTakedown.get(rateRecord.Loan__c) == null){
ratesForTakedown.put(rateRecord.Loan__c, rateRecord);
}
else if(rateRecord.Pending_State__c == CurrentInAg ||
rateRecord.Pending_State__c == CurrentInLAandAg){
Integer rateIter = 0;
While(rateIter < requestData.Rates.size()){
if(requestData.Rates.get(rateIter).TakedownId == rateRecord.Loan__c){
requestData.Rates.remove(rateIter);
break;
}
rateIter++;
}
}
else{
continue; //We already have a rate for this takedown
}
RateRequest rate = new RateRequest();
rate.TakedownId = rateRecord.Loan__c;
rate.RateId = rateRecord.Id;
Logic is missing to specifically look for "Current in Loan Accounting" row next if CurrentinAg is not there. please provide any suggestions on it.
Map<Id, Rate_Stream__c> ratesForTakedown = new Map<Id, Rate_Stream__c>();
for(Rate_Stream__c rateRecord : rates){
if(ratesForTakedown.get(rateRecord.Loan__c) == null){
ratesForTakedown.put(rateRecord.Loan__c, rateRecord);
}
else if(rateRecord.Pending_State__c == CurrentInAg ||
rateRecord.Pending_State__c == CurrentInLAandAg){
Integer rateIter = 0;
While(rateIter < requestData.Rates.size()){
if(requestData.Rates.get(rateIter).TakedownId == rateRecord.Loan__c){
requestData.Rates.remove(rateIter);
break;
}
rateIter++;
}
}
else{
continue; //We already have a rate for this takedown
}
RateRequest rate = new RateRequest();
rate.TakedownId = rateRecord.Loan__c;
rate.RateId = rateRecord.Id;
To implement the logic of specifically looking for "Current in Loan Accounting" row next if CurrentInAg is not there, you can modify the existing code to include an additional check after the first "else if" condition.
Here is one way to implement this logic:
Hope this helps !
Thank you.