+ Start a Discussion
Jordan RennertJordan Rennert 

Unable to create package version for package via Salesforce CLI and 2GP

The main issue is that we're currently unable to create a version of a package of an sfdx project we're building. Judging from the error's we've received, it's almost as if the temp files of our project are not updating properly via the CLI. However, without much visibility, we're unable to know for sure.

The most recent error when we run force:package:version:create is:
Multiple errors occurred:\n(1) TestSobjectTriggers: Variable does not exist: RecordTypeId\n(2) TestSobjectTriggers: Variable does not exist: FirstName\n(3) TestSobjectTriggers: Variable does not exist: LastName\n(4) TestSobjectTriggers: Variable does not exist: RecordTypeId\n(5) TestSobjectTriggers: Variable does not exist: FirstName\n(6) TestSobjectTriggers: Variable does not exist: LastName\n(7) TestSobjectTriggers: Variable does not exist: FirstName
However the unit tests in the TestSobjectTriggers class run fine.

Previously, it was complaining that the package was not defined in the sfdx-project.json, which was fixed by making it so temporary files would remain in the .sfdx directory. What I found there was that the file in the temp directory didn't match what was in the project directory.
Vishwajeet kumarVishwajeet kumar
Hello,
It could be due to some query not bringing the data, please check and make sure queried resources are part of package if this is the case.

From above error, issues are with variables : RecordTypeId, FirstName, LastName.


Thanks