You need to sign in to do that
Don't have an account?
KARIM 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
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
changed to component.set("v.reclamationList",reclamationList);
All Answers
changed to component.set("v.reclamationList",reclamationList);
you mean <aura:set attribute="else">