We're an ISV transitioning from a classic single org dev setup to DX. We're developing a first generation managed package. One of the problems we're running into is the use of System.requestVersion
in our code base.
The documentation of System.requestVersion
states:
The requestVersion method isn’t supported for unmanaged packages. If you call it from an unmanaged package, an exception will be thrown.
The code calling that method is running fine in our classic dev org, but when it is running in a scratch org, System.requestVersion
throws an exception that it cannot be called from unmanaged code.
Is there a way that you can set up your scratch org such that the code is running in a managed package?
My sfdx-project.json:
{
"packageDirectories": [
{
"path": "app",
"default": true,
"package": "p",
"versionNumber": "42.0.0"
}
],
"namespace": "n",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "44.0"
}
The values for "package" and "namespace" match with those in our dev org.
My project-scratch-def.json:
{
"orgName": "Company",
"edition": "Partner Developer",
"country": "NL",
"language": "NL",
"features": ["AuthorApex", "Communities", "MaxApexCodeSize:15"],
"orgPreferences" : {
"enabled": ["ChatterEnabled", "NetworksEnabled", "S1DesktopEnabled"]
}
}