You need to sign in to do that
Don't have an account?
Callum Whitehouse
aura if not working as expected within lightning component
I'm trying to display 'True' if the field 'Heliocare_360_Toolkit__c' is checked, however it only shows false even when the profile has this field checked.
<aura:component implements="forceCommunity:availableForAllPageTypes">
<aura:attribute name="title" type="String" default="Marketing Toolkit Repository"/>
<aura:attribute name="contact" type="Contact"/>
<lightning:card>
<aura:set attribute="title">
{! v.title }
</aura:set>
<aura:if isTrue="{!v.contact.Heliocare_360_Toolkit__c}">
True
<aura:set attribute="else">
False
</aura:set>
</aura:if>
</lightning:card>
</aura:component>
Can anyone see if I've made any obvious errors please?
<aura:component implements="forceCommunity:availableForAllPageTypes">
<aura:attribute name="title" type="String" default="Marketing Toolkit Repository"/>
<aura:attribute name="contact" type="Contact"/>
<lightning:card>
<aura:set attribute="title">
{! v.title }
</aura:set>
<aura:if isTrue="{!v.contact.Heliocare_360_Toolkit__c}">
True
<aura:set attribute="else">
False
</aura:set>
</aura:if>
</lightning:card>
</aura:component>
Can anyone see if I've made any obvious errors please?
===========================================================================
Component:
<aura:component implements="forceCommunity:availableForAllPageTypes,flexipage:availableForAllPageTypes" controller="FileRepositoryController">
<aura:attribute name="items" type="Contact[]"/>
<aura:attribute name="title" type="String" default="Marketing Toolkit Repository"/>
<aura:attribute name="contact" type="Contact" default="{'sObjectType':'Contact', 'Heliocare_360_Toolkit__c':false}"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<lightning:card>
<aura:set attribute="title">
{! v.title }
</aura:set>
<aura:if isTrue="{!v.items.Heliocare_360_Toolkit__c}">
True
<aura:set attribute="else">
False
</aura:set>
</aura:if>
</lightning:card>
</aura:component>
===========================================================================
Controller:
({
doInit : function(component, event, helper) {
var action = component.get("c.getItems");
action.setCallback(this, function(response){
var state = response.getState();
if (component.isValid() && state === "SUCCESS") {
component.set("v.items", response.getReturnValue());
}
});
$A.enqueueAction(action);
}
})
===========================================================================
Apex Class:
public class FileRepositoryController {
@AuraEnabled
public static List<Contact> getItems() {
List<Contact> TK = [SELECT Heliocare_360_Toolkit__c FROM Contact];
return TK;
}
}
RE: requirement - Download files are displayed to user if they have specific custom fields checked as true.
Do you have any advice please?
Component: Apex Class:
Controller: