You need to sign in to do that
Don't have an account?
Reduce Queries and Write all functionality in single query by using Map
Dear friends,
I like to reduce this Query size (four --> single ) . Kindly advise me once how it's possible by using Map
Regards,
Soundar Raj
+91-741842418
I like to reduce this Query size (four --> single ) . Kindly advise me once how it's possible by using Map
public class OppUsdUpdate { public static void usdUpdate(Id Opportunity, String str){ List<Opportunity> oppList = New List<Opportunity>(); List<Opportunity> oppQry = [Select id, name, USD_Amount1__c,Amount, Currency__c from Opportunity where Id =:Opportunity]; CurrencyType__c cTypeInr =[Select id,name,Conversion_Rate__c, ISO_Code__c from CurrencyType__c where ISO_Code__c = 'INR' Limit 1]; CurrencyType__c cTypeUsd =[Select id,name,Conversion_Rate__c, ISO_Code__c from CurrencyType__c where ISO_Code__c = 'USD' Limit 1]; CurrencyType__c cTypeEur =[Select id,name,Conversion_Rate__c, ISO_Code__c from CurrencyType__c where ISO_Code__c = 'EUR' Limit 1]; CurrencyType__c cTypeAud =[Select id,name,Conversion_Rate__c, ISO_Code__c from CurrencyType__c where ISO_Code__c = 'AUD' Limit 1]; /*INDIAN RUPEE*/ for(Opportunity opp : OppQry){ opportunity op = new Opportunity(Id = Opp.Id); if(opp.Currency__c == 'INR'){ op.usd_amount1__c = opp.Amount * cTypeInr.Conversion_Rate__c; } if(opp.Currency__c == 'USD'){ op.usd_amount1__c = opp.Amount * cTypeUsd.Conversion_Rate__c; //oppList.add(op); } if(opp.Currency__c == 'EURO'){ op.usd_amount1__c = opp.Amount * cTypeEur.Conversion_Rate__c; } if(opp.Currency__c == 'AUD'){ op.usd_amount1__c = opp.Amount * cTypeAUD.Conversion_Rate__c; } oppList.add(op); } if(oppList.size() > 0){ update opplist; } } }
Regards,
Soundar Raj
+91-741842418
All Answers
Thanks For your quick response.. I had make some changes based on Shruthi Optimized Code.
Really Hearty Thanks to spent your golden time for me.
Regards,
Soundar Raj
+91- 7418425418
Thanks for Optimized my Code as well. I have make few changes as per my knowledge (I Think few changes only).
1. It's a utilty class , This class is refered in one trigger.
2. Update Processing in trigger.
Class
Trigger
Regards,
Soundar Raj
+91-7418425418