• Benedetto Virzi 27
  • 0 Points
  • Member since 2016

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 0


I'm having a problem with .setParams, I've tried to put it in an app that is similar to the Account List explained in the trailhead(https://developer.salesforce.com/trailhead/en/project/slds-lightning-components-workshop/slds-lc-6). The objective is to pass, from an input field, two dates to the apex controller for filter the select of the objects and show them when the buttom "Cerca" is pressed. So I tried with the aura:attribute and the action.setParams to pass the values in the controller but I've always get the same error. I think that the problem is .setParams because when I remove it the app works fine.
The error is this:

Something has gone wrong. Error during init [TypeError: Cannot read property 'apply' of undefined] . Please try again.

This is the code:


<aura:application >
    <ltng:require styles="/resource/SLDS/assets/styles/salesforce-lightning-design-system.css"  />
    <div class="slds" style="margin-top:10px;margin-left:10px;">
       <c:AccountList DataDa="2016-01-01"  DataA="2016-01-31"/>


aura:component controller="LightningConsoleTitoliController">
   <aura:attribute name="titoli" type="List" />
       <aura:attribute type="Date" name="DataA" access="global"/>
    <aura:attribute type="Date" name="DataDa" access="global"/>
   <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<table class="slds-table slds-table--bordered slds-table--striped">
           <--Other Code -->
<ui:inputDate aura:id='DataDa' label='Data Da' value='{!v.DataDa}' displayDatePicker="true" updateOn='click'/>
           <ui:inputDate aura:id='DataA' label='Data A' value='{!v.DataA}' displayDatePicker="true" updateOn='click'/> 
           <ui:inputText aura:id='Agente' label='Agente' value='{!v.Agente}'/>
            <ui:button press='{!c.doInit}' aura:id='bottone' label='Cerca' />

<-- Other code -->

   doInit: function(component, event, helper) {      
      //Fetch the expense list from the Apex controller   

   //Fetch the accounts from the Apex controller
  getAccountList: function(component) {
      var action = component.get("c.getTitoli");
          DataA : component.get("v.DataA")
          DataDa : component.get("v.DataDa")
<-- Callback code -->

Apex Controller:
public class LightningConsoleTitoliController {
    public static list<Titolo__c> getTitoli(Date DataDa, Date DataA){
        return [Select id, Data_Scadenza__c, CreatedDate, Importo_Provvigionale__c,DataA__c,DataDa__c,
                Data_Scadenza_Inizio__c, Data_Scadenza_Fine__c from Titolo__c where Data_SCadenza__c >= :DataDa and Data_Scadenza__c <= :DataA];