You need to sign in to do that
Don't have an account?
Monika Baricza
lightning component returning opposite results
Hi,
I wrote a custom lightning opponent, which is finally working. I managed to add it to the Accounts page where the user should be able to see a list of commissions and the contacts who achieved them. I would like the user to see only the commissions that are related to that account. I added force:hasRecordId to the app and it seemed to be working until I realised that the app is only returning the contacts who have no accounts at all. I am a bit baffled by this so I appreciate any help.
Below is my code:
The Controller:
And the other controller:
Thank you very much
I wrote a custom lightning opponent, which is finally working. I managed to add it to the Accounts page where the user should be able to see a list of commissions and the contacts who achieved them. I would like the user to see only the commissions that are related to that account. I added force:hasRecordId to the app and it seemed to be working until I realised that the app is only returning the contacts who have no accounts at all. I am a bit baffled by this so I appreciate any help.
Below is my code:
<aura:application extends="force:slds" implements="force:hasRecordId" > <c:commissionsByAccount/> </aura:application>The component:
<aura:component controller="commissionController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" > <aura:attribute name="contacts" type="Commission__c[]" /> <aura:attribute name="commissions" type="Commission__c[]"/> <aura:handler name="init" action="{!c.doInit}" value="{!this}"/> <lightning:layout class="slds-page-header slds-page-header--object-home"> <lightning:layoutItem padding="around-small" size="4"> <lightning:icon iconName="standard:scan_card" alternativeText="Commissions"/> </lightning:layoutItem> <lightning:layoutItem padding="horizontal-small"> <div class="page-section page-header"> <h1 class="slds-text-heading--label">Commissions for this account</h1> <h1 class="slds-text-heading--medium">Commissions</h1> </div> </lightning:layoutItem> </lightning:layout> <lightning:layout> <lightning:layoutItem padding="around-small" size="12"> <table class="slds-table slds-table_cell-buffer slds-table_bordered"> <thead> <tr class="slds-line-height_reset"> <th aria-label="Date" aria-sort="descending" class="sdls-is-sortable" scope="col"> <div class="slds-truncate" title="Date">Date</div> </th> <th class="" scope="col"> <div class="slds-truncate" title="Name">Name</div> </th> <th class="" scope="col"> <div class="slds-truncate" title="Amount">Amount</div> </th> </tr> </thead> <tbody> <aura:iteration items="{!v.contacts}" var="com"> <tr class="slds-hint-parent"> <th data-label="Date" scope="row"> <div class="slds-truncate" title="Date"> <a href="javascript:void(0);" tabindex="-1">{!com.Date__c}</a> </div> </th> <td data-label="Name"> <div class="slds-truncate" title="Name">{!com.Contact_Name__r.Name}</div> </td> <td data-label="Amount"> <div class="slds-truncate" title="Amount">{!com.Commission_Amount__c}</div> </td> </tr> </aura:iteration> </tbody> </table> </lightning:layoutItem> </lightning:layout> </aura:component>
The Controller:
public class commissionController { @AuraEnabled public static List<Commission__c> getCommissions(String AccountID) { return [SELECT Commission_Amount__c, Date__c, Commission__c.Contact_Name__r.Name FROM Commission__c WHERE Commission__c.Contact_Name__r.Account.Id =: AccountID ]; } }
And the other controller:
({ doInit: function(component, event, helper) { var action = component.get("c.getCommissions"); action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS") { var res=response.getReturnValue(); component.set("v.contacts", response.getReturnValue()); console.log("Success"); } else { console.log("Failed with state: " + state); } }); // Send action off to be executed $A.enqueueAction(action); }, })
Thank you very much
I think you missed one part of lightning component controller.js you have to set params for the commision list.
1) lightning:recordID attribute in aura component.
2) Set param for the commision class in the controller.js
All Answers
I think you missed one part of lightning component controller.js you have to set params for the commision list.
1) lightning:recordID attribute in aura component.
2) Set param for the commision class in the controller.js