function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mike ChandlerMike Chandler 

How to leverage existing source in a new SFDX project?

I'm still getting my feet wet with SFDX and have stumbled on to a problem. I'm working on a new project and am deploying my code and metadata changes to a scratch org. The scratch org is vanilla and doesn't contain any of the metadata in my Sandbox org. I'm writing an Apex class that has a dependency on a class that is in my Sandbox but not in my scratch org.  I'd like to introduce this class into my project so that I can use it, but I have no intention of changing the class in any way. It's just a dependency, so I need it for reference and so my source push requests will compile.

How can I introduce existing code without making it a part of my SFDX project? I'm pretty confused about how to move forward.
Best Answer chosen by Mike Chandler
Khan AnasKhan Anas (Salesforce Developers) 
Hi Mike,

Greetings to you!

You can copy your Org’s Existing Code to an SFDX Project by creating an unmanaged package. Please refer to the below link which might help you further.

https://medium.com/eigen-x/how-to-copy-your-orgs-existing-code-to-an-sfdx-project-a3e9392f1a00

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas