0

I have two components 1)Top5Clients and 2)MessagesandAlerts which retrieves recodrs from their respective custom objects

I want to display the two components side by side so I have included in a MainComp component and when I am trying to execute MainComp by putting it in a lightning application getting the abobe error

Top5Clients helper logic

({

    getAllClients : function(component, event, helper) {

        var action = component.get("c.getTop5Clients");

        action.setCallback(this, function(a){

            component.set("v.TopClients", a.getReturnValue());

        });

        $A.enqueueAction(action);
    }

})

messages and Alerts helper logic

({

    getMessagesAndAlerts : function(component, event, helper) {

        var dupac = component.get("c.getMessagesAndAlerts");

        dupac.setCallback(this, function(m){

            component.set("v.MessageAlerts", m.getReturnValue());

        });

        $A.enqueueAction(dupac);
    }

})

I doubt some problem in the helper methods..pls suggest Please find the Top5Client code

<aura:attribute name="TopClients" type="TopClients__c[]"/>
 <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<ltng:require styles="/resource/SLDS202/assets/styles/salesforce-lightning-design-system.css"/>
<div class="slds-media__body">
  <p class="slds-page-header__title slds-truncate slds-align-middle" title="Messages and Alerts">Top 5 Clients</p>

</div>
    <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer">

        <thead>
        <tr class="slds-text-heading--label">
        <th scope="col"><span class="slds-truncate">Name</span></th>
        <th scope="col"><span class="slds-truncate">AUM</span></th>
        <th scope="col"><span class="slds-truncate">Cash</span></th>
        </tr>
        </thead>
        <tbody>
    <aura:iteration var="client" items="{!v.TopClients}">


               <tr>
                   <td scope="col">
              {!client.Name}
                       </td>
                   <td scope="col">
              {!client.AUM__c}
                       </td>
                   <td scope="col">
              {!client.Cash__c}
                       </td>

            </tr>

     </aura:iteration>

    </tbody>
    </table>

MessageAndAlertc code

    <div class="slds-media__body">
  <p class="slds-page-header__title slds-truncate slds-align-middle" title="Messages and Alerts">Messages and Alerts</p>

</div>



<table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer">

        <thead>
        <tr class="slds-text-heading--label">
        <th scope="col"><span class="slds-truncate">AlertType</span></th>
        <th scope="col"><span class="slds-truncate">Alertsource</span></th>
        <th scope="col"><span class="slds-truncate">AlertDescription </span></th>
          <th  scope="col"><span class="slds-truncate">Account </span></th>
            <th scope="col"><span class="slds-truncate">AlertDate </span></th>
        </tr>
        </thead>
        <tbody>

    <aura:iteration var="client" items="{!v.MessageAlerts}">

           <tr>
                   <td scope="col">

              {!client.Alert_Type__c}
                       </td>
                   <td scope="col">
              {!client.Alert_Source__c}
                       </td>
                   <td scope="col">
              {!client.AlertDescription__c}
                       </td>
               <td scope="col">
              {!client.Account__c}
                    </td>
               <td scope="col">
              {!client.Alert_Date__c}
                    </td>
                        </tr>

     </aura:iteration>

        </tbody>


    </table>

Trying to print data from top5clients,messageandalert custom object

when i try to run Lightning application with top5clients and mesaagesandalert facing the error when run independently the components are working fine

<div class=""> 
     <div>

        <table id="page-table">
            <tr>
                <td class="col-sm-6 col-md-6 page-table-td">

                    <c:Top5Clients />        
                </td>
                <td class="col-sm-6 col-md-6 page-table-td">
                 <c:MeaasgeandAlert /> 

                </td>
             </tr>
        </table>                 
     </div>

</div>

After the error I can see output for Top5Clients but not for messagesandalert..table printing only column headings but not data

  • can you share the <c:top5client/> component code as well to debug the issue? – Praveen Jul 15 '16 at 10:50
  • yes, Top5Clients's component code – Praveen Jul 15 '16 at 11:12
0

Seems like your server side controller is returning a Collection, while your component is expecting an array for the attribute "TopClients".

This might be causing issues because you're trying to convert a List into an array. Or some other incompatible data type.

Please check your server side controller

  • What do you mean by converting a List into an array? – itzmukeshy7 Mar 27 '18 at 5:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.