• Jay wang 1
  • NEWBIE
  • 1 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
I'm getting an error when checking the Using Visualforce Pages in Page Layouts and Mobile Cards challenge. The error says that the page isn't evaluating the 'Prospecting' stage, yet the code works when I insert an Opportunity Id where the Stage = Prospecting.

The code:
<apex:page docType="html-5.0" standardController="Opportunity">
    <style>
    </style>
    
    <apex:remoteObjects >
        <apex:remoteObjectModel name="Opportunity" fields="Id,StageName" />
    </apex:remoteObjects>
    
    <div class="myPage">
        <h2>Tip for when you're in the {!Opportunity.StageName} Stage:</h2>
        <p id="stageTip" />
    </div>
    
    <script>
        var opportunityStage = "{!Opportunity.StageName}";
        document.getElementById("stageTip").innerHTML = createStageTip();
        
        function createStageTip() {
            if(opportunityStage){
                switch(opportunityStage){
                    case "Prospecting":
                        return "You need to ask really good questions"
                        break;
                    case "Needs Analysis":
                        return "Determine the needs by asking really good questions"
                        break;
                    case "Proposal/Price Quote":
                        return "Make sure the price doesn't exceed the budget"
                        break;
                    case "Negotiation/Review":
                        return "Maybe go down, but don't go down too much"
                        break;
                    default:
                        return "Use your best judgement";
                }
            }
        }
    </script>
</apex:page>
If you have any ideas as to why this isn't working, I'd love to hear them.

Cheers,
Justin
 
  • December 07, 2015
  • Like
  • 1