+ Start a Discussion
Prerna Raj 7Prerna Raj 7 

Error Variable does not exist

I am new to coding and am still learning. I am getting the error for  "variable does not exist : i " in my code below -   I have made the 2 lines in which i am getting the error bold

trigger LeadingCompetitor on Opportunity (before insert, before update) {
    for (Opportunity opp : Trigger.new){
        //Add all prices to our list in order of competitors
            List<Decimal> competitorPrices = New List<Decimal>();
        //Add all competitors to our list in order 
            List<String> competitorName = New List<String>();
        //Loop throughall competitors to find the position of the lowest price
            Decimal lowestPrice;
            Integer lowestPricePosition;
            for (Integer i = 0; i < competitorPrices.size(); i++); {
                Decimal currentPrice = competitorPrices.get(i);
                if(lowestPrice == Null || currentPrice < lowestPrice) {
                    lowestPrice = currentPrice;
                     lowestPricePosition = i;
        //Populate the leading competitor field with the competitor matching the lowest price position
                   opp.Leading_Competitor__c = competitorName.get(lowestPricePosition);
Prathyusha Balguri 4Prathyusha Balguri 4
The error is in  line  -  for (Integer i = 0; i < competitorPrices.size(); i++); {
Remove ';' before the curly brace. 
Prerna Raj 7Prerna Raj 7
Thank you so much....:)