Salesforcedx-vscode: ERROR: sObject type 'PackageLicense' is not supported.

Created on 24 Oct 2018  路  4Comments  路  Source: forcedotcom/salesforcedx-vscode

Summary

Hello everyone. Getting error "ERROR: sObject type 'PackageLicense' is not supported." when attempting to run tests

Steps To Reproduce:

  1. Created empty project with manifest
  2. Authorized org
  3. Fetched data from org with "Retrieve Source from Org"
  4. Clicked vial icon in vscode leftside tab
  5. Refreshed available tests with refresh button
  6. Clicked green arrow to run all tests

Expected result

Tests performed, results printed in console

Actual result

Starting Run Apex test(s)
sfdx force:apex:test:run --tests [test class name].[test method name] --resultformat human --outputdir C:\Users\someuser\AppData\Local\Temp --loglevel error
ERROR: sObject type 'PackageLicense' is not supported.
sfdx force:apex:test:run --tests [test class name].[test method name] --resultformat human --outputdir C:\Users\someuser\AppData\Local\Temp --loglevel error ended with exit code 1

Additional information

VS Code Version: 1.27.1
SFDX CLI Version: 6.36.0
OS and version: Windows 7 SP1 (x64)

vscode-core-44.2.0
vscode-apex-44.2.0
sfdx --version: sfdx-cli/6.36.0 (windows-x64) node-v10.5.0
sfdx-cli was updated with npm install sfdx-cli --global instead of sfdx update
all interaction with org done through company proxy
nowhere in tests PackageLicense used explicitly
org api version defined in package.xml is 41.0
this is non-DX project

Would appreciate any input on this issue. Thank you.

Most helpful comment

Issue was resolved. Apparently have nothing to do with vscode/sfdx-cli/vscode cli plugin.

tldr: 'PackageLicense' is not supported because in user's profile 'Manage Package Licenses' checkbox was deactivated. So every time sfdx-cli tried to execute tests it also tried to fetch PackageLicense object, and this object is unavailable.

How to fix: in Salesforce go to Settings->type in 'profiles' in quick search-> Select 'Profiles' under 'Users' section. It will list all available profiles in your sandbox org. Pick profile that is related with user you are trying to execute tests for. Click 'Edit' to edit profile. Search web-page for 'Manage Package Licenses' and activate checkbox.

Now this user, who is under this profile, will be able to use PackageLicense standard object. You don't need to manage packages per se to run tests, but sfdx-cli won't be able to use PackageLicense without 'Manage Package Licenses' permission. Also queries like SELECT Id FROM PackageLicense will now work for you.

All 4 comments

Apparently PackageLicense sobject is not supported in sandboxes.
When I executed SELECT Id FROM PackageLicense in my sandbox I got ERROR: sObject type 'PackageLicense' is not supported.
Same query returns successfully when executed in production environment.

Updated sfdx-cli to 6.37.0. Still facing this issue.

Issue was resolved. Apparently have nothing to do with vscode/sfdx-cli/vscode cli plugin.

tldr: 'PackageLicense' is not supported because in user's profile 'Manage Package Licenses' checkbox was deactivated. So every time sfdx-cli tried to execute tests it also tried to fetch PackageLicense object, and this object is unavailable.

How to fix: in Salesforce go to Settings->type in 'profiles' in quick search-> Select 'Profiles' under 'Users' section. It will list all available profiles in your sandbox org. Pick profile that is related with user you are trying to execute tests for. Click 'Edit' to edit profile. Search web-page for 'Manage Package Licenses' and activate checkbox.

Now this user, who is under this profile, will be able to use PackageLicense standard object. You don't need to manage packages per se to run tests, but sfdx-cli won't be able to use PackageLicense without 'Manage Package Licenses' permission. Also queries like SELECT Id FROM PackageLicense will now work for you.

@StanZha - Just wanted to say thank you for writing the clear summary on how you resolved the issue (even if it has nothing to do with our extensions). Posting your tldr; will make it searchable for anyone else on the web seeing this issue.

IntelliJ + Illuminated Cloud is able to execute unit tests just fine without the "Manage Package Licenses" permission, but switching to Visual Studio Code this error occurs. Curious as to why the VS Code extension even needs to look at the PackageLicense object to execute a unit test when other tools do not?

Was this page helpful?
0 / 5 - 0 ratings