0

I have a class where I have declared @RemoteAction functions to work using Javascript Remoting.

When I only had one function everything was working fine, but when I created a second @RemoteAction function the browser console was displaying the following error:

Visualforce Remoting Exception: Method 'getCallsDetail' not found on controller RqaCallsList. Check spelling, method exists, and/or method is RemoteAction annotated.

I checked the javascript code and also the Apex code and everything is ok, there are not problems with the names or anything like that.

Javascript code:

RqaCallsList.getCallsList(startDate, endDate, token, function(result,event){
        if(event.status){
            results = result;
            var headers = ['Date','Campaign','Campaign Type','Disposition','Agent','Call Recording','QA Score','ANI','DNIS'];
            var tableContent = createTable(results,headers);
            table.empty();
            table.append(tableContent);
            toDataTable(table);
            $j('#loading').hide();
        }
    });
}


RqaCallsList.getCallsDetail(startDate, endDate, token, function(result,event){
        if(event.status){
            results = result;
            var headers = ['Date','Campaign','Campaign Type','Disposition','Agent','Call Recording','QA Score','ANI','DNIS'];
            var tableContent = createTable(results,headers);
            table.empty();
            table.append(tableContent);
            toDataTable(table);
            $j('#loading').hide();
        }
    });
}

Apex code:

@RemoteAction
    public static List<Call__C> getCallsList(String startDate, String endDate, String token){
        calls = new List<Call__c>();
        identifier = sendCallLogRequest(startDate, endDate, token);
        isRunning = checkCallLogIsRunning(identifier, token);
        if(isRunning)
            calls = getCallLogResult(identifier, token);
        else{
            MessageManager.addMessage(ApexPages.Severity.ERROR, 'The call log service is not running');
            return null;
        }
        return calls;
    }

@RemoteAction
    public static List<Call__C> getCallsDetail(String startDate, String endDate, String token){
        calls = new List<Call__c>();
        identifier = sendCallLogRequest(startDate, endDate, token);
        isRunning = checkCallLogIsRunning(identifier, token);
        if(isRunning)
            calls = getCallLogResult(identifier, token);
        else{
            MessageManager.addMessage(ApexPages.Severity.ERROR, 'The call log service is not running');
            return null;
        }
        return calls;
    }

The syntax is correct because I'm using a Static Resource where I have all the javascript functions.

What could be wrong with my code?

  • 2
    You definitely can. Something else must be going on here. – Adrian Larson Jun 7 '18 at 20:48
  • The format of my variables is being changed suddenly for each function, I don't know why is this happening but it's a Javascript error. – Manu Jun 7 '18 at 20:57
1

You don't seem to have the javascript functions separated by a comma. Not sure if that is a copy/paste thing or not, but I forget that all the time..

| improve this answer | |
  • 1
    Without showing specifically what you're referring to, this would seem to have been better posted as comment rather as an answer. – crmprogdev Jun 11 '18 at 17:47
  • The question is: "What could be wrong with my code?" Why is this not an answer? – Guy Clairbois Jun 12 '18 at 11:40
0

The params variables type are changing separately for each function and that's creating a mismatching error in the Apex controller.

The values types have to equal in the Javascript controller and also in the Apex controller.

From now I will always do a double check of all my variables before sending them to the Apex controller.

| improve this answer | |
0

I realise this is an old question but for the sake of a definitive answer, and a pointer for others:

Yes you can have multiple @RemoteAction Methods

The way you call you function in JS has to match the signature in Apex, i.e. the parameters you pass must be in the right order and of the correct types. Datetimes in particular can be a pain as you need to use unix style timestamps, nothing else works, and if I recall correctly you can't pass null for those.

One other thing to watch out for is that if you have an unitialised JavaScript varible (i.e. it's value is undefined) that's being passed as a parameter, then you'll see this error about the method does not exist as the serialiser can't match the call you're making with the Apex function signature.

| improve this answer | |

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.