I feel like I'm missing something basic here..
My scenario:
Using SFDX project, NOT using scratch orgs (for reasons), retrieving and deploying to a dev sandbox.
Currently have a managed package installed on the sandbox (a Docusign package from the appExchange)
Said managed package metadata is not part of my local SFDX project (this is the problem I'm trying to solve)
Have written an apex class in my local SFDX project that references a class+method that is part of this Docusign package.
This is giving me a reference error in VS Code, as the project does not see the Docusign apex class
I tried SFDX force:source:retrieve -m ApexClass
, but that didn't pull the classes in the package
Specifying the class name didn't help, as it wasn't found.
I also tried: SFDX force:source:retrieve -n "DocuSignPkgName"
... which retrieves the pkg successfully, sure, but puts it in its own directory structure rather than integrating it into the project folder. This doesn't help me address the reference error I'm getting.
Am I not supposed to be able to include managed package components in my SFDX project? If not, how are we supposed to effectively develop against package components?
Edit to respond to SFDCFox
To give your solution a try, here's how I updated my sfdx-project.json
file:
From
{
"packageDirectories": [
{
"path": "force-app",
"default": true
}
],
"namespace": "",
"sfdcLoginUrl": "https://test.salesforce.com",
"sourceApiVersion": "45.0"
}
To
{
"namespace": "",
"sfdcLoginUrl": "https://test.salesforce.com",
"sourceApiVersion": "45.0",
"packageDirectories": [
{
"package": "unlockedPackageTest",
"versionNumber": "0.1",
"path": "force-app",
"default": true,
"dependencies": [{
"package": "Docusign Apps [email protected]"
}]
}
],
"packageAliases": {
"Docusign Apps [email protected]": "04t3u000003X3cuAAC"
}
}
Now I'm not clear, but it seems like with this change I've just A) declared that my sfdx project is now an unlocked package with a name and version number, and B) claimed that my package has a dependency on the installed Docusign package
However, I'm not sure what to do with this change to my json file. I tried another SFDX force:source:retrieve
on the project to see if it would now pull in the depended-upon package metadata, but it did not. Plus, the dependency error is still showing up in the Problems tab of my homemade class in VS Code, and in the deployment errors if I try to push to my sandbox.
I have confirmed that the apex class and its method that I am referencing in my own code is Global
, and that if I were to recreate my class directly in sandbox via dev console, the reference error wouldn't appear.
The problem I'm trying to solve seems to be purely getting VSCode + SFDX to retrieve and acknowledge this dependency.