• Prathyusha Balguri 4
  • NEWBIE
  • 15 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
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>();
            competitorPrices.add(opp.Competitor_1_Price__c);
            competitorPrices.add(opp.Competitor_2_Price__c);
            competitorPrices.add(opp.Competitor_3_Price__c);
       
        //Add all competitors to our list in order 
            List<String> competitorName = New List<String>();
            competitorName.add(opp.Competitor_1__c);
            competitorName.add(opp.Competitor_2__c);
            competitorName.add(opp.Competitor_3__c);
        
        //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);
                
    
    }    
}
i have a requirment to create list view on lead object to present the leads owned by any any active user in the user's business team. i know this feature is not avaliable in salesforce, what is avaliable i nsalesforce is  :
  • All leads
  • My Leads
  • Queue Lead 
lead owner

what i am trying to implement it is "My Team's Lead" list view , that means any lead owned by me or anyone in my team. the nearest implementation for the team in my org is the user public group. my idea is creating a new formula checkbox field in the lead object named "My Team" and set this checkbox to True if the lead owner is any user in any public group of the user public groups. my question is : can i do that in salesforce in my case ? if yes , how i do this checking ?. if not , is there any suggsted solutions to implement this requirment ?