1

I have lightning component with several callouts to server-side controller and they work except one! It is absolutely same, but the action doesn't run at all, Callback function doesn't run. Parts of code: Helper function:

({
searchInFiles : function(component, searchedText) {
    var action = component.get("c.searchFiles");
    action.setParams({
        "searchedText" : searchedText, 
        "returningFilesAmount" : 10
    });
    action.setCallback(this, function(response) {
        var state = response.getState();
        if (state === "SUCCESS") {
            component.set("v.SearchResults", response.getReturnValue());
            console.log(response.getReturnValue());
        } else {
            console.log("Failed with state: " + state);
            console.log("Return value: " + response.getReturnValue());
        }
    });
    console.log();
    $A.enqueueAction(action);
}
})

The function in server-side controller exist and work fine, the attribute in component exist and has the same datatype as returning value in server-side function. lightning component and apex controller tied and another callouts work ok. Please, help me to find where is the problem

2
  • Could you add the method signature of the apex method you are trying to invoke?
    – dsharrison
    Dec 30, 2016 at 17:30
  • Are you sure that searchInFiles function is called? Can you add a log statement and check
    – manjit5190
    Dec 31, 2016 at 15:41

1 Answer 1

2

It is this part that is wrong.

 action.setParams({
     "searchedText" : searchedText, 
     "returningFilesAmount" : 10
 });

There is no "" around the parameters.

It should be:

action.setParams({
     searchedText : searchedText, 
     returningFilesAmount : 10
});

Also, check your parameters names, if they are same as in your Apex class.

See the guide on Server-Side Action.

1
  • 5
    The quotes don't hurt anything (but I personally dislike them), but I'd guess possibly a case-sensitive name thing.
    – sfdcfox
    Dec 30, 2016 at 17:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .