I am getting an odd bug where capitalizing the first letter of an Apex method that returns a map, causes an error within the javascript controller.


var action = component.get("c.OpAddOnCount");

Apex Controller:

public static Map<String,Integer> OpAddOnCount() {...}

When I capitalize the name in both JS and Apex, I get an error. However, if I make the first letter a lowercase 'o' (in both JS and Apex), everything works fine.

I am new to JS, is there an obvious syntax issue that I am unaware of? I want to make sure I don't get hung up on something like this again for so long!

  • Yep the case needs to match. Surprised about what you've seen through. Have you treble checked that you have changed both consistently i.e. both to upper case?
    – Keith C
    Commented Jul 10, 2019 at 19:18
  • what is the name of the JS function that has the var action line? It must be named differently than the Apex Method. Quirky, but it is what it is. Commented Jul 10, 2019 at 19:21
  • Yes, I even copied and pasted so I knew I had the cases matching exactly. For some reason is still only works when the "o" is lowercase.
    – Rory
    Commented Jul 10, 2019 at 19:21
  • Name of the JS function is doInit.
    – Rory
    Commented Jul 10, 2019 at 19:27

1 Answer 1


While Salesforce's naming conventions for Apex are optional in general, this isn't the case with Aura-linked server-side controller methods. I suspect this is due to JavaScript convention expectations (and that many IDEs will whinge if uppercase letters start function names that are not constructor functions [and vice versa]).

I can't say that I've seen any documentation on this one, but I certainly hit this same problem myself a year or two back.

Some useful reading here as well about parameter naming and the need to avoid name overloading on the client-side.

You must log in to answer this question.

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