10

Environment

  • sfdx-cli/7.58.2 win32-x64 node-v12.16.3
  • API 48

What's going on?

When trying to create a managed packaged version with Second Generation Packaging (2GP) -with code check- that contains this class:

global with sharing class VersionClass {
    global static void controlMethod() {
        String foo = 'someString';
    }

    global static void versionMethod() {
        Version packageVersion = System.requestVersion();
    }
}

the following error occur when calling the method containing System.requestVersion(); 1

(1) Apex Test Failure: Class.foobarbaz.VersionClass.versionMethod: line 8, column 1
  Class.foobarbaz.TestVersionClass.test_versionMethod: line 17, column 1 System.ProcedureException: Method is not supported from an unmanaged namespace

Such errors do not occur with the First Generation Packaging.

What's the expected behavior?

We expect the managed package version to be created without any errors while using 2GP.

How to reproduce?

  1. Clone the MRC Repo
  2. Ensure that you're setup for 2GP
  3. Try to create a version. You should get the aforementioned error.

Notes

1: This occurs outside of Apex test calls as well. We originally found the issue by calling a similar method through a RemoteAction in a VisualForce Page. But let's keep it simple for the example sake.

  • Note, the error is not reproducable without the codecheck (-c flag). Edited OP accordingly. – Louis Bompart Jun 5 at 18:07
0

After contacting Salesforce, I had confirmation that Version is, to this day, not supported in 2GP, which caused the issue described here.

| improve this answer | |

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.