+ Start a Discussion
KARIM EL ALAOUIKARIM EL ALAOUI 

Please Help creating lighting component

I have been configuring ligthning component and its gone well so far. However I am struggling to find out why the new component doesnt display information, we have reclamation custom objet with lookup relation with contact and I need to display all relamations related to a contact in ligthning component under contact, see bellow all config:

ReclamationListController.apxc
public class ReclamationListController {
        
    @AuraEnabled
    public static List<Reclamation__c> getReclamationList(List<Id> contactIds) {
                List<Reclamation__c> reclamationList = [SELECT Id, Name, Type__c, Description__c, Contact__c FROM Reclamation__c WHERE Contact__c in :contactIds];
        return reclamationList;
    }
}
**************************************************
ReclamationList.cmp

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" controller="ReclamationListController" access="global" >
    <!-- Handler to call function when page is loaded initially -->
    <aura:handler name="init" action="{!c.getReclamationsList}" value="{!this}" />
    <aura:attribute name="reclamationList" type="List" />
        <lightning:card title="Reclamations">
        <p class="slds-p-horizontal_small">       
            <aura:iteration items="{!v.reclamationList}" var="reclamation"> 
                <lightning:recordViewForm recordId="{!reclamation.Id}" objectApiName="Reclamation__c">
                    <div class="slds-box slds-theme_default">
                        <lightning:outputField fieldName="Name" />
                        <lightning:outputField fieldName="Type__c" />
                        <lightning:outputField fieldName="Description__c" />
                    </div>             
                </lightning:recordViewForm>
                <br />
            </aura:iteration>
        </p>

        <aura:set attribute="actions">
            <lightning:button label="New" onclick="{!c.newReclamation}" />
        </aura:set>
    </lightning:card>
</aura:component>
**************************************************************
ReclamationsListController.js

({

        getReclamationsList : function(component, event, helper) {

                helper.fetchReclamations(component, event, helper);
        },

    newReclamation: function(component, event, helper) {
        var createReclamation = $A.get("e.force:createRecord");
        createReclamation.setParams({
            "entityApiName": "Reclamation__c",
            "defaultFieldValues": {
                "Contact__c": component.get("v.recordId")
            }
        });
        createReclamation.fire();
    }
})

*****************************************
ReclamationsListHelper.js

({
        fetchReclamations : function(component, event, helper) {
        var action = component.get("c.getReclamationList");
        var contactId = component.get("v.recordId");
        action.setParams({
            contactIds: contactId

        });

        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state === 'SUCCESS') {

                var reclamationList = response.getReturnValue();

                component.set("v.contactList",reclamationList);
            }
            else {
                alert('Error in getting data');
            }
        });
        $A.enqueueAction(action);
        }    
})


*********

Thank you for your halp
Best Answer chosen by KARIM EL ALAOUI
Nayana KNayana K
component.set("v.contactList",reclamationList); line should be
changed to component.set("v.reclamationList",reclamationList);

All Answers

Nayana KNayana K
component.set("v.contactList",reclamationList); line should be
changed to component.set("v.reclamationList",reclamationList);
This was selected as the best answer
KARIM EL ALAOUIKARIM EL ALAOUI
I am struggling to figure out how to display an avatar image  depenting to custom object field value, we have reclamation custom object with lookup relation with contact and I need to display all relamations related to a contact in lightning component under contact and for each reclamation I need to display a static ressource avatar image depending to the value stored on type__c, do you have any idea please?

 
Nayana KNayana K
<aura:iteration items="{!v.reclamationList}" var="reclamation">
<aura:if isTrue="{!reclamation.Type__c == 'value1'}"> 
  <img src="{!$Resource.resourceName + '/assets/images/avatar1.png'}"/>
<aura:set attribute="false">
    <aura:if isTrue="{!reclamation.Type__c == 'value2'}"> 
  <img src="{!$Resource.resourceName + '/assets/images/avatar2.png'}"/>
<aura:set attribute="false">
   <aura:if isTrue="{!reclamation.Type__c == 'value3'}"> 
  <img src="{!$Resource.resourceName + '/assets/images/avatar13png'}"/>
<aura:set attribute="false">
   
</aura:set>
</aura:if>
</aura:set>
</aura:if>
</aura:set>
</aura:if>
 
</aura:iteration> 
 
It's an if-else-if structure. Please let me know if you don't understand. 
Please correct if any syntax mistakes present.
KARIM EL ALAOUIKARIM EL ALAOUI
instead of <aura:set attribute="false"> 
you mean <aura:set attribute="else">
 
Nayana KNayana K
Yes. Sorry about that.  I typed this in mobile. Was sleepy too. 
KARIM EL ALAOUIKARIM EL ALAOUI
Thank you Nayana for your help