You need to sign in to do that
Don't have an account?
MaheemSam
Trigger causing 50k limit exception
Hi,
Please help to change below trigger this is cauing system.limit.exception not sure where the issue is but still I am getting this error please suggest me.
Thanks
Sudhir
Please help to change below trigger this is cauing system.limit.exception not sure where the issue is but still I am getting this error please suggest me.
Trigger convertToUSD on Opportunity (before update){ Try { List<String> oppiso = new List<String>(); List<date> cdate = new List<date>(); List<DatedConversionRate> DatedConversion = [SELECT isocode,startdate,ConversionRate FROM DatedConversionRate] ; Opportunity conopp = [select CurrencyIsoCode,amount,closedate from opportunity where id = :trigger.newmap.keyset() ]; for(Opportunity o : trigger.new) { oppiso.add(o.CurrencyIsoCode); cdate.add(o.closedate); } Double cts = [SELECT ConversionRate FROM DatedConversionRate where isocode IN :oppiso and startdate <= :cdate order by startdate desc limit 1].conversionRate; for(Opportunity ops : trigger.new) { ops.CURRENCY_RATE__c = cts; } } catch (System.LimitException e) { system.debug('Exception going more than 50k+'); } catch (Exception e) { system.debug(e); for(Opportunity ops : trigger.new) { ops.CURRENCY_RATE__c = null; } } }
Thanks
Sudhir
Please update your code like below
All Answers
May I suggest you please refer the below link for reference with similar kind of issue.
- https://salesforce.stackexchange.com/questions/28228/system-limitexception-too-many-query-rows-50001
Hope it will be helpful.Please mark it as best answer if the information is informative.so that question is removed from an unanswered question and appear as a proper solution.
Thanks
Rahul Kumar
Please update your code like below