function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RajivRajiv 

This page has an error. You might just need to refresh it. Error in $A.getCallback() [event.getParam is not a function. (In 'event.getParam("Final_wrappers")', 'event.getParam' is undefined)]

Hello Everyone,

In salesforce lighting, I am trying to push records into the search wrapper class using a component event. However, I am getting continuously below error
TThis page has an error. You might just need to refresh it. Error in $A.getCallback() [event.getParam is not a function. (In 'event.getParam("Final_wrappers")', 'event.getParam' is undefined)] Callback failed"

Could anyone help me on this, I am trying to figure out what's the problem.

Here is my code:
Component 1

<aura:component controller="AccountController">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="wrappers" type="Account_Wrapper" />
    <aura:attribute name="accounts" type="Account" />
    
    <aura:registerEvent name="loadMyEvent" type="c:Result"/>


    <span class="big">Choose Accounts</span>
    <table>
    <tr>
        <th class="head">Name</th>
        <th class="head">View?</th>
    </tr>
    <aura:iteration items="{!v.wrappers}" var="wrap">
    <tr>
        <td class="cell">
        <ui:outputText value="{!wrap.acc.Name}" />
        </td>
        <td class="cell">
        <ui:inputCheckbox value="{!wrap.selected}" />
            </td>
    </tr>
    </aura:iteration>
    </table>
    <button onclick="{!c.getAccounts}">Get Accounts</button>
    <span class="big">Selected Accounts</span>
    <table>
        <tr>
            <th class="head">Name</th>
            <th class="head">Industry</th>
            <th class="head">Website</th>
        </tr>
        <aura:iteration items="{!v.accounts}" var="acc">
            <tr>
                <td class="cell">
                <ui:outputText value="{!acc.Name}" />
                </td>
                <td class="cell">
                <ui:outputText value="{!acc.Industry}" />
                </td>
                <td class="cell">
                <ui:outputText value="{!acc.Website}" />
                </td>
            </tr>
    </aura:iteration>
    </table>
    <c:SearchAccountController /> 
</aura:component>

--------------------------------------------------------------------
Componet 1 Helper Class

({
    init : function(cmp, ev) {
        var action = cmp.get("c.GetAccountNames");
 
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var accs=response.getReturnValue()
                var wrappers=new Array();
                for (var idx=0; idx<accs.length; idx++) {
                    var wrapper = { 'acc' : accs[idx], 
                                    'selected' : false
                                    };
                    wrappers.push(wrapper);
                }
                alert('wrappers2'+wrappers);
                cmp.set('v.wrappers', wrappers);      
            }
            else if (state === "ERROR") {
                alert('Error : ' + JSON.stringify(errors));
            }
        });
        $A.enqueueAction(action);
    },
    getAccounts : function(cmp, ev) {
        var action = cmp.get("c.GetAccountDetails");
        var wrappers=cmp.get('v.wrappers');
        alert('wrappers1'+wrappers);
        var ids=new Array();
        for (var idx=0; idx<wrappers.length; idx++) {
            if (wrappers[idx].selected) {
                ids.push(wrappers[idx].acc.Id);
            }
        }
        var idListJSON=JSON.stringify(ids);
        action.setParams({
                   "idListJSONStr": idListJSON
        });
 
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var accs=response.getReturnValue()
                cmp.set('v.accounts', accs);
                alert('accsssss'+accs);
                console.log('accccccc'+accs);
                var evt = $A.get("e.c:Result");
                alert('eventttt'+evt);
                console.log('evttttttt'+evt);
                evt.setParams({"Final_wrappers":accs});
                evt.fire();
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                alert('Error : ' + JSON.stringify(errors));
            }
        });
       
        $A.enqueueAction(action);
    }
})

-----------------------------------------------------------------

Component 2


<aura:component controller="AccountController">
    <ltng:require styles="{! $Resource.SLDS24+ '/assets/styles/salesforce-lightning-design-system.css'}"/>
    <aura:attribute name="wrappers" type="Account_Wrapper"/>
    <aura:attribute name="accounts" type="Account" />
    <aura:attribute name="searchResult" type="List" description="use for store and display account list return from server"/>
    <aura:attribute name="searchKeyword" description="use for input" type="string" ></aura:attribute>
    <aura:attribute name="Message" type="boolean" default="false" description="use for display no record found message"/>
    <aura:handler event="c:Result" action="{!c.SearchJS}"/>


    <div class="slds-m-around--large">
       <form class="slds-form--inline"> 
         <div class="slds-form-element"> 
            <label class="slds-form-element__label" for="Search">Account Search</label>  
              <div class="slds-form-element__control" >
                <ui:inputtext aura:id="searchId" value="{!v.searchKeyword}" placeholder="Type Account Name"  class="slds-input"></ui:inputtext>
              </div>
            </div> 
             <div class="slds-form-element">
                 <button type="Button" onclick="{!c.SearchJS}" class="slds-button slds-button--brand">Search</button>
                 </div>
        </form>   
         <table class="slds-table slds-table--bordered slds-table--cell-buffer">
            <thead>
                <tr class="slds-text-title--caps">
                    <th scope="col">
                         <div class="slds-truncate" title=" Name"> ID</div>
                    </th>
                    <th scope="col">
                         <div class="slds-truncate" title=" Name"> Name</div>
                    </th>   
                     <th scope="col">
                          <div class="slds-truncate" title="Type">Type</div>
                       </th>
                       <th scope="col">
                          <div class="slds-truncate" title="Industry">Industry</div>
                       </th>
                       <th scope="col">
                          <div class="slds-truncate" title="Phone">Phone</div>
                       </th>
                       <th scope="col">
                          <div class="slds-truncate" title="Fax">Fax</div>
                       </th>
                </tr>
            </thead>
            <tbody>
                 <aura:if isTrue="{!v.Message}">
               <div class="slds-text-color--error"> No Result Found...</div>
            </aura:if>
                <aura:iteration items="{!v.wrappers}" var="Wrap"> 
                <span>
                <tr>
                <td>
                    <div class="slds-truncate">{!Wrap.acc.Id}</div>
                </td>
                <!--  <td>
                  <div class="slds-truncate">{!Wrap.acc.name}</div>
                  </td>
                  <td>
                     <div class="slds-truncate">{!Wrap.acc.Type}</div>
                  </td>
                  <td>
                     <div class="slds-truncate">{!Wrap.acc.industry}</div>
                  </td>
                    <td>
                     <div class="slds-truncate">{!Wrap.acc.Phone}</div>
                  </td>
                  <td>
                     <div class="slds-truncate">{!Wrap.acc.fax}</div>
                  </td> -->
                  </tr>
                </span>
                </aura:iteration>     
            </tbody>
        </table> 
      </div>     
     
</aura:component>

---------------------------------------------------------------------------------

Component 2 Helper Class

({
    searchHelper: function(component, event) {
        var action = component.get("c.searchmethod");
                
        alert('====key'+component.get("v.searchKeyword"));
        
        action.setParams({
            'searchKeyword': component.get("v.searchKeyword")         
        });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var storeResponse = response.getReturnValue();
                // if storeResponse size is 0 ,display no record found message on screen.
                if (storeResponse.length == 0) {
                    component.set("v.Message", true);
                } else {
                    component.set("v.Message", false);
                
                }
                var wrappers=new Array();
               
                for (var idx=0; idx<storeResponse.length; idx++) {
                   var wrapper = { 'acc' : storeResponse[idx],
                   'selected' : false
                            };
                    
               wrappers.push(wrapper);
                    alert('alert1');
                    alert('wrappers3'+wrappers);
               var showResultValue = event.getParam("Final_wrappers");
                  alert('showResultValue'+showResultValue);
               component.set(wrappers,showResultValue);
               alert('Wrapper2'+wrappers);
                    alert('--wrapper--'+wrappers);
            } 
                 // component.set("v.searchResult", storeResponse);
                   component.set('v.wrappers', wrappers);
                   
                alert('==='+component.set("v.searchResult", storeResponse));
                     
            } 
 
        });
        $A.enqueueAction(action);
 
    }
})

------------------------------------------------------------------------------------------------------------------

Event 

<aura:event type="APPLICATION" description="Event template">
    <aura:attribute name="Pass_Result" type="string"/>
    <aura:attribute name="Final_wrappers" type="Account_Wrapper"/>
</aura:event>

If anyone can help me on this like what I am doing wrong, It would be really helpful. I am trying from 6-7 hours and not able to figure it out what's the problem. 

Warm regards,
Rajiv
Alain CabonAlain Cabon
Hi,

You should post the code of SearchJS of your controller. The controller classes (Javascript) are missing.

The call of the helper function in SearchJS could be wrong.