function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Willi WerkelWilli Werkel 

OpportunityStageTips Trailhead Challenge

Hi,
I am doing the "Add a Mobile Card that Displays Content Based on Opportunity Stage" challenge. It asks for a Visualforce page which displays content depending on opportunity stage.
I used the following code
       <apex:outputText rendered="{!CONTAINS(opportunity.stagename,'Prospecting')}" value="this is a good idea" />
       <apex:outputText rendered="{!CONTAINS(opportunity.stagename,'Analysis')}" value="do this" />
       <apex:outputText rendered="{!CONTAINS(opportunity.stagename,'Proposal')}" value="do that" />
       <apex:outputText rendered="{!CONTAINS(opportunity.stagename,'Negotiation')}" value="go away" />
and it works in the browser, but the challenge checks complains:
"The page isn't evaluating the 'Prospecting' stage. "
Any idea why?
 
Himanshu ParasharHimanshu Parashar
Hi WIlli,

Perhaps it  is explicitly looking for True and False statement in rendered condition or perhaps not supporting Contains in that case.

Following code worked for me.
 
<apex:page docType="html-5.0" standardController="Opportunity" title="Detals">

   <apex:outputPanel rendered="{!if(Opportunity.stagename=='Prospecting',true,false)}">
        This is prospecing tips
   </apex:outputPanel>
   <apex:outputPanel rendered="{!if(Opportunity.stagename=='Needs Analysis',true,false)}">
        This is without prospecing tips
   </apex:outputPanel>
   
   <apex:outputPanel rendered="{!if(Opportunity.stagename=='Proposal/Price Quote',true,false)}">
        This is without prospecing tips
   </apex:outputPanel>
   
   <apex:outputPanel rendered="{!if(Opportunity.stagename=='Negotiation/Review',true,false)}">
        This is without prospecing tips
   </apex:outputPanel>
</apex:page>

Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Willi WerkelWilli Werkel
Hi Himanshu,

indeed the challenge check seems to have problems recognizing the CONTAINS function. When I modified my code to this
       <apex:outputText rendered="{!if(Opportunity.stagename=='Prospecting',true,false)}" value="this is a good idea" />
       <apex:outputText rendered="{!CONTAINS(opportunity.stagename,'Analysis')}" value="do this" />
       <apex:outputText rendered="{!CONTAINS(opportunity.stagename,'Proposal')}" value="do that" />
       <apex:outputText rendered="{!CONTAINS(opportunity.stagename,'Negotiation')}" value="go away" />

the check complained about "Need Analysis" check missing.

Trailhead developers: your chance to improve this great training program a tiny little bit.

Willi
 
Himanshu ParasharHimanshu Parashar
Hi Willi,

That is correct. they are doing exact match instead of contains. They should improve this.

Thanks,
Himanshu
Brian NewboldBrian Newbold
Hey folks.. I'm evaluating with a CASE statement.. Is this appropriate, just an unchecked solution? Or am I missing something?
<apex:page docType="html-5.0" standardController="Opportunity">
    <style>
        .mypage {
            font-size: 24px;
            text-align: center;
            color: green;
        }
    </style>
    
    <script src='/canvas/sdk/js/publisher.js'></script>

    <apex:remoteObjects>
        <apex:remoteObjectModel name="Opportunity" fields="StageName"/>
    </apex:remoteObjects>
    
    <div class="mypage">
        <p>Stage: {!Opportunity.StageName}</p>
        <p>Tip  : {!CASE(
        	Opportunity.StageName, 
            	'Prospecting', 'Keep Dialing', 
        		'Needs Analysis', 'Youre Needy', 
        		'Proposal/Price Quote', 'Quote it Dude!',
        		'Negotiation/Review', 'Close it!',
        	'What Stage is that?')}</p>   
	</div>
</apex:page>

 
Rian O'Dwyer 5Rian O'Dwyer 5
The neatest answer I found on this is the selected answer at:
https://developer.salesforce.com/forums/?id=906F0000000MHKkIAO

The original post had used the same approach I was using, i.e. javascript. The end result is great. it uses the Salesforce resources rather than trying to do it by conventional programming.
Parker EdelmannParker Edelmann
Thanks for posting that link Rian O'Dwyer. I've submitted a feedback card explaining the issue. I've had good luck with that and usually get a return email at some point. As of right now, the CASE() function technically fulfills the requirements, but does not meet challenge "standards." Will try to let you know what happens.
Efraim Taranto 1Efraim Taranto 1
I've passed the challenge by using this code:
<apex:page standardController="Opportunity">
    <apex:outputText rendered="{!Opportunity.StageName=='Prospecting'}">Tips for prospecting</apex:outputText>
    <apex:outputText rendered="{!Opportunity.StageName=='Needs Analysis'}">Tips for Needs Analysis</apex:outputText>
    <apex:outputText rendered="{!Opportunity.StageName=='Proposal/Price Quote'}">Proposal/Price Quote</apex:outputText>
    <apex:outputText rendered="{!Opportunity.StageName=='Negotiation/Review'}">Tips for Negotiation/Review</apex:outputText>
</apex:page>