If I log into my Developer Account at Salesforce and open the Developer Console
, then I can click "New" and create a custom Apex Class
. I might give it name such as:
SearchResultsController
If I go back a few days later, and log in, I can click "Open" to re-open this class. And now I see that it's full name is:
SearchResultsController.apxc
That ending, apxc, is added automatically by Salesforce.
But if I go to https://force-cli.heroku.com/ and download that for my Mac, and then run:
force export
I get a huge number of files, and if I look in the "classes" folders, I see some of the custom Apex classes that I created, but now they have a cls
extension, for instance:
metadata/classes/SearchResultController.cls
Why is this? Why would the same code have different endings in different places? Does Salesforce respect both apxc
and cls
as legitimate extensions for the code that I write?
Best Answer
I suspect the apxc extension for Apex classes and apxt for triggers is specific to the Developer Console.
.cls
and.trigger
are the extensions that the Metadata API expects.The Developer Console uses the Tooling API to get and update the body of the of apex classes, triggers, etc... As such, it is missing the extensions that the Metadata API exposes.
My guess is that the developer console needs to add extensions for the editor that it uses. If you search in the source of ApexIDECore.js there are references to the extensions:
Either it doesn't support longer extensions like
.trigger
so they needed to come up with a shortened scheme or they just ignored the existing extension scheme and came up with a new one.If you are putting things in source control, stick with the extensions that the Metadata API expects and ignore the developer console.