9

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?

  • The standard extensions virtually everywhere are .cls, .trigger, etc. The Developer Console is the outlier here, so I re-tagged your question with that in mind. – Adrian Larson Oct 31 '16 at 19:46
7

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 file suffix is .cls for the class file. The accompanying metadata file is named ClassName-meta.xml. Source

The file suffix is .trigger for the trigger file. The accompanying metadata file is named TriggerName-meta.xml. Source

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:

getExtension:function(a){return"apxc"}

getExtension:function(a){return"apxt"}

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.

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.