I have the following functions in the aura helper js file:
getSearchTimeframePicklistValues: function(component, event, helper) {
var action = component.get("c.getSearchTimeframePicklistValues");
action.setCallback( this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var results = response.getReturnValue();
component.set("v.searchTimeframes", results.framesList);
component.set("v.defaultTimeframeId", results.defaultId);
component.find("searchTimeframePicklist").set("v.value", results.defaultId);
component.set("v.selectedSearchTimeFrame", results.defaultId);
window.setTimeout(
$A.getCallback(this.setStartEndDates(component, event, helper)));
}
});
$A.enqueueAction(action);
},
setStartEndDates: function(component, event, helper) {
var searchTimeframes = component.get("v.searchTimeframes");
var selectedTimeFrame = component.get("v.selectedSearchTimeframe");
var startingNumberOfDays, endingNumberOfDays;
for (var i=0; i < searchTimeframes.length; i++) {
if(selectedTimeFrame == searchTimeframes[i].Id) {
startingNumberOfDays = searchTimeframes[i].Start__c;
endingNumberOfDays = searchTimeframes[i].End__c;
break;
}
}
if(startingNumberOfDays == undefined && endingNumberOfDays == undefined) {
component.set("v.startDate", "");
component.set("v.endDate", "");
}
else {
component.set("v.startDate", helper.buildFormattedDate(startingNumberOfDays));
component.set("v.endDate", helper.buildFormattedDate(endingNumberOfDays));
}
},
The getSearchTimeframePicklistValues
function is called in the doInit
function when the component initializes. I'm getting the following error:
AuraError: Assertion Failed!: $A.getCallback(): 'callback' must be a valid Function : false`
Is the syntax wrong? Although I'm getting the error, if I close the error the UI displays the results correctly.