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
Mark GallagherMark Gallagher 

Condtional statements in lightning markup

<aura:component  implements="flexipage:availableForAllPageTypes" access="global" >
    <aura:if isTrue="{!$Lead.Sys_Household__c == 'Wally West Jesse Quick'}">
        <img src="{!$Resource.Flash}"/>
    <aura:set attribute="else"> 
        <p>False </p>
    </aura:set>
    </aura:if>
</aura:component>

I am trying to get a picture to show up based on a condition the problem is that I know this condition to be true, but it is giving the False output. 
Raj VakatiRaj Vakati
Use this code
 
<aura:component  implements="flexipage:availableForAllPageTypes" access="global" >
<aura:attribute name="leadObj" type="Lead" default="{'sObjectType':'Lead', 'Sys_Household__c':'Wally West Jesse Quick'}"/>


    <aura:if isTrue="{!v.leadObj.Sys_Household__c == 'Wally West Jesse Quick'}">
        <img src="{!$Resource.Flash}"/>
    <aura:set attribute="else"> 
        <p>False </p>
    </aura:set>
    </aura:if>
</aura:component>

 
Mark GallagherMark Gallagher
Thanks, but when I change the record to make the condition false it still shows the Image I need it to actually evaluate based on the information in the record
Raj VakatiRaj Vakati
It's working for me ..  see the details info here. in this example if i pass the lead name as Wally West Jesse Quick  it will show image other wise it will show false 

Code
 
<aura:attribute name="leadObj" type="Lead" default="{'sObjectType':'Lead', 'Name':'Wally West Jesse Quick'}"/>
    
    
    <aura:if isTrue="{!v.leadObj.Name == 'Wally West Jesse Quick'}">
        	<img src="{!$Resource.StaticResourceName}"/>

        
        <aura:set attribute="else"> 
            <p>False </p>
        </aura:set>
    </aura:if>
Result 
User-added image




Code 
 
<aura:attribute name="leadObj" type="Lead" default="{'sObjectType':'Lead', 'Name':' Not Wally West Jesse Quick'}"/>
    
    
    <aura:if isTrue="{!v.leadObj.Name == 'Wally West Jesse Quick'}">
        	<img src="{!$Resource.StaticResourceName}"/>

        
        <aura:set attribute="else"> 
            <p>False </p>
        </aura:set>
    </aura:if>

Result: false 
Mark GallagherMark Gallagher
Maybe I'm not being clear I need to get the name of the lead object from the record its self not harcode the name into the component. I need to access the name field of whatever lead record this component this on. So if I put this component on the lead page layout then open up the Bruce Wayne lead it should show false, but show the image on the Wally West Jesse Quick lead.
Raj VakatiRaj Vakati
Can you share te complete code? so i can able to rewrite it for you 
Mark GallagherMark Gallagher
That is the complete code I've written nothing else
Raj VakatiRaj Vakati
Use this code
<aura:component description="OpportunityTestComponent" implements="flexipage:availableForRecordHome,force:hasRecordId">
    <aura:attribute name="record" type="Object"
                    description="The record object to be displayed"/>
    <aura:attribute name="leadRecord" type="Object"
                    description="A simplified view record object to be displayed"/>
    
    
    <force:recordData aura:id="record"
                      layoutType="FULL"
                      recordId="{!v.recordId}"
                      targetError="{!v.recordError}"
                      targetRecord="{!v.record}"
                      targetFields="{!v.leadRecord }"
                      mode="VIEW"/>
    
    <aura:if isTrue="{!v.leadRecord.Sys_Household__c== 'Wally West Jesse Quick'}">
        <img src="{!$Resource.Flash}"/>
        
        
        <aura:set attribute="else"> 
            <p>False </p>
         </aura:set>
    </aura:if>
    
</aura:component>