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

  • Could you add the method signature of the apex method you are trying to invoke? – dsharrison Dec 30 '16 at 17:30
  • Are you sure that searchInFiles function is called? Can you add a log statement and check – manjit5190 Dec 31 '16 at 15:41
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.

  • 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 '16 at 17:10

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.