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
Alastair Scollay 8Alastair Scollay 8 

Error when checking 'Using Expressions' challenge

I realise this question has been asked a few times already but couldn't find any suggested solution that worked for me, so here goes.....

I am currently trying to complete the 'Using Expressions' challenge on the Trailhead Lightning site, and keep getting the same error.

Code
 Component
<aura:component >
    <aura:attribute name="IsSunday" type="Boolean" default="false"/>
    <aura:attribute name="IsMonday" type="Boolean" default="false"/>
    <aura:attribute name="IsTuesday" type="Boolean" default="false"/>
    <aura:attribute name="IsWednesday" type="Boolean" default="false"/>
    <aura:attribute name="IsThursday" type="Boolean" default="false"/>
    <aura:attribute name="IsFriday" type="Boolean" default="false"/>
    <aura:attribute name="IsSaturday" type="Boolean" default="false"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    <aura:if isTrue="{!v.IsSunday}">
    <p>Today is Sunday</p>
   </aura:if>
   <aura:if isTrue="{!v.IsMonday}">
    <p>Today is Monday</p>
    </aura:if>
    <aura:if isTrue="{!v.IsTuesday}">
    <p>Today is Tuesday</p>
    </aura:if>
    <aura:if isTrue="{!v.IsWednesday}">
    <p>Today is Wednesday</p>
    </aura:if>
    <aura:if isTrue="{!v.IsThursday}">
    <p>Today is Thursday</p>
    </aura:if>
    <aura:if isTrue="{!v.IsFriday}">
    <p>Today is Friday</p>
    </aura:if>
    <aura:if isTrue="{!v.IsSaturday}">
    <p>Today is Saturday</p>
    </aura:if>
</aura:component>

CONTROLLER
({
    doInit : function(component) {
        var theDate = new Date();
        if (theDate.getDay()==0) {component.set("v.IsSunday", true);}
        if (theDate.getDay()==1) {component.set("v.IsMonday", true);}
        if (theDate.getDay()==2) {component.set("v.IsTuesday", true);}
        if (theDate.getDay()==3) {component.set("v.IsWednesday", true);}
        if (theDate.getDay()==4) {component.set("v.IsThursday", true);}
        if (theDate.getDay()==5) {component.set("v.IsFriday", true);}
        if (theDate.getDay()==6) {component.set("v.IsSaturday", true);}
    }
})

ERROR
Challenge not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: ZPWCUPZG

I tried creating a new Developer edition, as per a suggestion on another thread, but got the same error (albeit with a different error id).

I went back to my original developer edition and tried another suggestion - modifying the code in my component to have only one <aura:if> statement and one <aura:set attribute....> tag, as shown below:

<aura:component >
    <aura:attribute name="IsSunday" type="Boolean" default="false"/>
    <aura:attribute name="IsMonday" type="Boolean" default="false"/>
    <aura:attribute name="IsTuesday" type="Boolean" default="false"/>
    <aura:attribute name="IsWednesday" type="Boolean" default="false"/>
    <aura:attribute name="IsThursday" type="Boolean" default="false"/>
    <aura:attribute name="IsFriday" type="Boolean" default="false"/>
    <aura:attribute name="IsSaturday" type="Boolean" default="false"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    <aura:if isTrue="{!v.IsSunday}">
    <p>Today is Sunday</p>
        <aura:set attribute="else">
                Today is not Sunday
        </aura:set>
    </aura:if>

<!-- Commented out code -->
    <!-- <aura:if isTrue="{!v.IsMonday}">
    <p>Today is Monday</p>
    </aura:if>
    <aura:if isTrue="{!v.IsTuesday}">
    <p>Today is Tuesday</p>
    </aura:if>
    <aura:if isTrue="{!v.IsWednesday}">
    <p>Today is Wednesday</p>
    </aura:if>
    <aura:if isTrue="{!v.IsThursday}">
    <p>Today is Thursday</p>
    </aura:if>
    <aura:if isTrue="{!v.IsFriday}">
    <p>Today is Friday</p>
    </aura:if>
    <aura:if isTrue="{!v.IsSaturday}">
    <p>Today is Saturday</p>
    </aura:if> -->
<!-- Commented out code -->

</aura:component>

Same end result:
Challenge not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: MEEOAPTN

Any help would be appreciated. have spent quite a lot of time on this already!
William TranWilliam Tran
For this exercise, I believe you don't need to get that complicated:

Something like simple should do it.  The controller is not even needed

Thx
<aura:component >
	  <aura:attribute name="DayOfTheWeek" type="String" default="Monday"/>
 <aura:if isTrue="{!v.DayOfTheWeek =='Monday'}" >
     
     	<aura:text value="{! 'Today is' + v.DayOfTheWeek}"/>

</aura:if>

</aura:component>

The key is to use an expression.


 
Alastair Scollay 8Alastair Scollay 8
Thanks for the feedback, William. You're probably right about my over-complicating the answer!

For what it's worth, the error message turned out to be something of a red herring. I thought that there was some kind of issue with my environment. In fact, what actually ended up fixing it was simply changing all my attribute/variable names to those specified in the challenge. For example, instead of using 'v.IsSunday', 'v.IsMonday' etc....I used v.DayOfTheWeek and set it to "Sunday", or "Monday" etc...

Similarly, in the component, I changed the test from <aura:if isTrue="{!v.IsSunday}">.....to <aura:if isTrue="{!v.DayOfTheWeek=='Sunday'}">

Hope this helps anyone else who has run into the same issue.
Andrew EversleyAndrew Eversley
Thanx for your input William Tran, you are stellar as per usual. 
William TranWilliam Tran
Andrew, glad you got it to work.  Please mark best answer.

thx