0

I am having trouble understanding the capabilities of a scratch org. I am in need of someone to take a look and see if it is set up incorrectly or if I am understanding it's capabilities wrong.

My confusion comes in with how I am able to create/edit classes and push and pull data with scratch orgs.

I believe I have the scratch org set up in Intellij successfully. I am able to see all metadata under MDAPI folder. It is to my understanding that I should not develop in this folder, rather I should develop in the DX folder.

The confusion I have is there is no src folder under the DX folder, so where would I add a new class? How do I made edits to the classes if they are not included in the DX folder? When I do make a new class in the MDAPI folder, the IDE throws an error on all objects can not resolve symbol: Custom_Object_Name__c

I am clearly either understanding the DX capabilities wrong or the scratch org is not fully set up yet.

Any help would be GREATLY appreciated!

enter image description here

enter image description here

enter image description here

  • Components in a typical DX project resides under force-app/main/default location. The path for classes in a DX project is /force-app/main/default/classes. So you will need to put your classes out there. – Jayant Das Jan 30 at 19:59
  • Awesome thank you, the classes are there, this helps a lot. The second issue is - Cannot resolve symbol 'Custom_Object_Name__c' less... (⌘F1) I notice in the DX folder the objects are simply listed like Custom_Object_Name__c but in the MDAPI folder the objects are listed like Custom_Object_Name__c.object. Why is there a .object at the end of one and not the other? I assume this is why I am getting the error. – Olivia Jan 30 at 20:23
  • I added details as an answer providing link to the documentation, which should help. I have also updated the title of the question to reflect the actual ask. – Jayant Das Jan 30 at 20:39
1

DX project structure is different than the Metadata format. You will get more information on Salesforce DX Project Structure and Source Format.

A Salesforce DX project has a specific project structure and source format. Salesforce DX source uses a different set of files and file extensions from what you’re accustomed when using Metadata API.

For your question:

The confusion I have is there is no src folder under the DX folder

The source folder in a DX project is under force-app/main/default. All the components viz., classes, lightning aura/web components, objects are stored under this folder.

E.g., you will find classes under force-app/main/default/classes.

As for your question from comment:

Why is there a .object at the end of one and not the other?

It's again because of the reason that the structure between MD API and DX is different. The below excerpt from the documentation link provided above details this:

Before, all custom objects and object translations were stored in one large metadata file.

A Salesforce DX project stores custom objects and custom object translations in intuitive subdirectories.

  • 1
    thank you this helped a lot. I realized that my metadata was not properly pulled into the DX folder. I had to re-connect to the default org, this created a new scratch org (that was titled '_' which confused me), connected to this new scratch org, refreshed the cache, and regenerated the offline table. When I reloaded the project I was able to see the metadata. Thank you! – Olivia Jan 30 at 21:27
1

Salesforce DX keeps the source files in a specific location, check out both the force-app/main/default folder and the sfdx-project.json file. You should be able to use Salesforce DX commands and scratch orgs to:

1) create a scratch org and launch it in a browser

2) use the setup menu to change things in the scratch org

3) pull changes from a scratch org to the local Salesforce DX folder

4) edit local files in the Salesforce DX folder like Apex Classes

5) push those changes back to the scratch org

You don't need a Metadata API folder for any of these activities. The Metadata API keeps files in a different format, that is why Custom Objects are in a single file for the Metadata API with the .object extension and in a hierarchy of folders for Salesforce DX. The reason Salesforce DX does this is to make DX folders easier to compare in remote repositories.

There are commands to convert back and forth between the Salesforce DX and the Metadata API file format. You only need to do that when you are moving Metadata into or out of a non-scratch org. Hope that helps.

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.