• Steven Payne
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I've been doing David Liu's excellent Apex Academy courses to try and get introduced to Apex coding. But he uses MavensMate as his editor, which has now been dropped.

Using the built in Salesforce Developer Console, I get tonnes of errors. I've gone through and doubled checked all my code and I am pretty confident it is correct.

So what is causing all of these errors???

Price Wars demo

and here is my code:

trigger LeadingCompetitor on Opportunity (before insert, before update) {
    
    for (Opportunity opp : Trigger.new) {
        // all of our prices in a list in order of competitor
        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 of our competitors in a list in the same order
        List<String> competitors = List<String>();
        competitors.add(opp Competitor_1__c);
        competitors.add(opp Competitor_2__c);
        competitors.add(opp Competitor_3__c);
        
        //  loop through all the competitors to find the position of the lowest price
        Decimal lowestPrice;
        Integer lowestPricePosition;
        for (Interger 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 = competitors.get(lowestPricePosition);
    }

}
I'm getting the following error when Checking the challenge for the Enable Salesforce Knowledge component of the Knowledge Basics module in Trailhead even though everything is set up correctly according to the article. Knowledge is enabled, the language is set and the user has the appropriate permission. What am I missing?

User-added image
User-added image
User-added image