1

Updating my Question Again : I started a new project, got fresh source and created a new package. No problem. Still stuck on creating a new version with eh same Project-scratch-def.json and sfdx-project.json.

I am down to one error: (1) Commute_Schedule_Confirmation: Update_Ground_Travel_Energy_User_Record (Update Records) - The object "GroundTravelEnrgyUse" can't be updated through a flow.

I am wondering if this is because in the NetZeroAuditor and NetZeroManager permission sets (OOB and uneditable) the failing field (GroundTravelEnrgyUse.Distance) is not checked for Read Access or Edit Access. I have a permission set with these in it I added to the sfdx-project.json but that didn't help..

{
  "packageDirectories": [
    {
      "path": "force-app",
      "default": true,
      "package": "HWWUnlocked415",
      "versionName": "ver 0.1",
      "versionNumber": "0.1.0.NEXT",
      "versionDescription": "",
      "definitionFile": "config/project-scratch-def.json",
      "apexTestAccess": {
        "permissionSets": [
            "NetZeroAuditor",
            "NetZeroManager",
            "Admin_Permission_Set" 
        ] ,
        "permissionSetLicenses": [
            "NetZeroCloudUserPsl"
        ]
    }
    }
  ],

Updating my Question after trying the first suggestion: Thank so much for the prompt response! I tried updating my sfdx-project-json as shown below. I am still getting the errors - some are still related to apex code and some are not. Actually same set of errors but the order changed a little.. lol Any thoughts on my json file and/or the errors? I also have a couple custom permission sets in my package I tried in addition to the NZC permissions in the json file with the same results.

Command sfdx force:package:beta:version:create -p HWWUnlocked411 --wait 10 -v DevHub --installationkeybypass

sfdx-project-json

   {
  "packageDirectories": [
    {
      "path": "force-app",
      "default": true,
      "name": "force-app",
      "fullPath": "C:\\Users\\xxxxx\\HWWPACKAGETEST4\\force-app\\",
      "package": "HWWUnlocked411",
      "versionName": "ver 0.1",
      "versionNumber": "0.1.0.NEXT",
      "apexTestAccess": {
        "permissionSets": [
            "NetZeroAuditor",
            "NetZeroManager" 
        ] ,
        "permissionSetLicenses": [
            "NetZeroCloudUserPsl"
        ]
    }
    }
  ],
  "name": "DevHub",
  "namespace": "",
  "sfdcLoginUrl": "https://xxxxx.lightning.force.com",
  "sourceApiVersion": "55.0",
  "packageAliases": {
    "HWWUnlocked411": "0Ho8c00000000hzCAA"
  }
}

Errors ERROR running force:package:beta:version:create: Package version creation failed with unknown error. Hybrid_Work_Wizard_Admin__c.Ground_Travel_Emissions_Factor__c: referenceTo value of 'GroundTravelEmssnFctr' does not resolve to a valid sObject type Hybrid_Work_Wizard_Admin__c.Telecommute_Emissions_Source__c: referenceTo value of 'Scope3EmssnSrc' does not resolve to a valid sObject type HybridWorkWizard/Commute_Emissions_Month_Department_5Eo: invalid report type HybridWorkWizard/Commute_Emissions_by_Month_Facility_1Q9: invalid report type HybridWorkWizard/Commute_Emissions_by_Month_Vehicle_Typ_XZL: invalid report type HybridWorkWizard/Commute_Emissions_by_Month_kf3: invalid report type HybridWorkWizard/Employees_EEUs_Commute_Survey_Month_fel: invalid report type HybridWorkWizard/Employees_by_Facility_by_Day_fMD: invalid report type HybridWorkWizard/Employees_with_EEUs_and_Commute_Survey_dVZ: invalid report type HybridWorkWizard/Telecommute_Emissions_by_Month_g3c: invalid report type HybridWorkWizard/bpqmOJNDYaEASDTJDgeUOjSNdmdznA: In field: report - no Report named HybridWorkWizard/Telecommute_Emissions_by_Month_g3c found Commute_Survey_Object__c-Commute Survey Object Layout: In field: relatedList - no CustomField named GroundTravelEnrgyUse.Commute_Survey__c found Employee_Energy_Use__c-Employee Energy Footprint Layout: In field: field - no CustomField named Employee_Energy_Use__c.Stationary_Asset_Environmental_Source__c found Employee__c-Employee Layout: Invalid field:Stationary_Asset_Environmental_Source__c in related list:Employee_Energy_Use__c.Employee__c Hybrid_Work_Wizard_Admin__c-Hybrid Work Wizard Admin Layout: In field: field - no CustomField named Hybrid_Work_Wizard_Admin__c.Ground_Travel_Emissions_Factor__c found HWWGenerateMonthlyItems: Invalid type: Scope3CrbnFtprnt HWWGenerateMonthlyItems: Invalid type: GroundTravelEnrgyUse HWWGenerateMonthlyItems: Invalid type: HotelStayEnrgyUse HWWGenerateMonthlyItems: SELECT ID, Commute_Emissions_Source__c, Telecommute_Emissions_Source__c ^ ERROR at Row:1:Column:12 No such column 'Commute_Emissions_Source__c' on entity 'Hybrid_Work_Wizard_Admin__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. HWWGenerateMonthlyItems: Variable does not exist: Commute_Emissions_Source__c HWWGenerateMonthlyItems: Variable does not exist: Telecommute_Emissions_Source__c HWWGenerateMonthlyItems: Invalid type: Scope3CrbnFtprnt HWWGenerateMonthlyItems: Variable does not exist: s3cftprtREF HWWGenerateMonthlyItems: Variable does not exist: s3cftprt HWWGenerateMonthlyItems: Variable does not exist: s3cftprt HWWGenerateMonthlyItems: Variable does not exist: s3cftprt HWWGenerateMonthlyItems: Variable does not exist: s3cftprt HWWGenerateMonthlyItems: Variable does not exist: s3cftprt HWWGenerateMonthlyItems: Variable does not exist: s3cftprt HWWGenerateMonthlyItems: Variable does not exist: sc3CarbonFP HWWGenerateMonthlyItems: Id,Average_Commute_Mileage__c,Ground_Travel_Emissions_Factor__c ^ ERROR at Row:1:Column:38 No such column 'Ground_Travel_Emissions_Factor__c' on entity 'Employee_Energy_Use__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. HWWGenerateMonthlyItems: Variable does not exist: Ground_Travel_Emissions_Factor__c HWWGenerateMonthlyItems: Variable does not exist: Hotel_Stay_Emissions_Factor__c HWWGenerateMonthlyItems: Variable does not exist: Ground_Travel_Emissions_Factor__c HWWGenerateMonthlyItems: Variable does not exist: Hotel_Stay_Emissions_Factor__c HWWGenerateMonthlyItems: Invalid type: GroundTravelEnrgyUse HWWGenerateMonthlyItems: Variable does not exist: gteu HWWGenerateMonthlyItems: Variable does not exist: gteu HWWGenerateMonthlyItems: Variable does not exist: gteu HWWGenerateMonthlyItems: Variable does not exist: gteu HWWGenerateMonthlyItems: Variable does not exist: gteu HWWGenerateMonthlyItems: Variable does not exist: gteu HWWGenerateMonthlyItems: Variable does not exist: gteu HWWGenerateMonthlyItems: Variable does not exist: gteu HWWGenerateMonthlyItems: Variable does not exist: gteu HWWGenerateMonthlyItems: Variable does not exist: gteu HWWGenerateMonthlyItems: Variable does not exist: gteu HWWGenerateMonthlyItems: Invalid type: Scope3CrbnFtprnt HWWGenerateMonthlyItems: Variable does not exist: grtrEnergyUseToInsert HWWGenerateMonthlyItems: Invalid type: HotelStayEnrgyUse HWWGenerateMonthlyItems: Variable does not exist: hseu HWWGenerateMonthlyItems: Variable does not exist: hseu HWWGenerateMonthlyItems: Variable does not exist: hseu HWWGenerateMonthlyItems: Variable does not exist: hseu HWWGenerateMonthlyItems: Variable does not exist: hseu HWWGenerateMonthlyItems: Variable does not exist: hseu HWWGenerateMonthlyItems: Variable does not exist: hseu HWWGenerateMonthlyItems: Variable does not exist: hseu HWWGenerateMonthlyItems: Variable does not exist: hseu HWWGenerateMonthlyItems: Variable does not exist: hseu HWWGenerateMonthlyItems: Variable does not exist: hseu HWWGenerateMonthlyItems: Variable does not exist: hotelStayEnergyUseToInsert HWWGenerateMonthlyItems: Invalid type: Scope3CrbnFtprnt HWWGenerateMonthlyItems: Method does not exist or incorrect signature: void add(Scope3CrbnFtprnt) from the type List HWWGenerateMonthlyItems: Invalid type: GroundTravelEnrgyUse HWWGenerateMonthlyItems: Method does not exist or incorrect signature: void add(GroundTravelEnrgyUse) from the type List HWWGenerateMonthlyItems: Invalid type: HotelStayEnrgyUse HWWGenerateMonthlyItems: Method does not exist or incorrect signature: void add(HotelStayEnrgyUse) from the type List HWWGenerateMonthlyItemsTEST: Invalid type: GroundTravelEmssnFctr HWWGenerateMonthlyItemsTEST: Invalid type: HotelStayEmssnFctr HWWGenerateMonthlyItemsTEST: Variable does not exist: gtef HWWGenerateMonthlyItemsTEST: Variable does not exist: htef HWWGenerateMonthlyItemsTEST: Variable does not exist: gtef HWWGenerateMonthlyItemsTEST: Variable does not exist: htef HWWGenerateMonthlyItemsTEST: Variable does not exist: gtef HWWGenerateMonthlyItemsTEST: Variable does not exist: htef HWWGenerateMonthlyItemsTEST: Invalid type: Scope3EmssnSrc HWWGenerateMonthlyItemsTEST: Variable does not exist: Commute_Emissions_Source HWWGenerateMonthlyItemsTEST: DML requires SObject or SObject list type: Scope3EmssnSrc HWWGenerateMonthlyItemsTEST: Variable does not exist: Commute_Emissions_Source__r HWWGenerateMonthlyItemsTEST: Variable does not exist: Telecommute_Emissions_Source__r TestDataFactory: Invalid type: GroundTravelEmssnFctr TestDataFactory: Invalid type: HotelStayEmssnFctr TestDataFactory: Invalid type: GroundTravelEmssnFctr TestDataFactory: Variable does not exist: newGroundTravelEmssnFctr TestDataFactory: Variable does not exist: newGroundTravelEmssnFctr TestDataFactory: DML requires SObject or SObject list type: GroundTravelEmssnFctr TestDataFactory: Invalid type: HotelStayEmssnFctr TestDataFactory: Variable does not exist: newHotelStayEmssnFctr TestDataFactory: Variable does not exist: newHotelStayEmssnFctr TestDataFactory: DML requires SObject or SObject list type: HotelStayEmssnFctr TestDataFactory: Variable does not exist: Ground_Travel_Emissions_Factor__c TestDataFactory: Variable does not exist: Hotel_Stay_Emissions_Factor__c Admin_Permission_Set: In field: field - no CustomField named Employee_Energy_Use__c.Ground_Travel_Emissions_Factor__c found User_Permission_Set: In field: field - no CustomField named Employee_Energy_Use__c.Ground_Travel_Emissions_Factor__c found Commute_Schedule_Confirmation: Update_Ground_Travel_Energy_User_Record (Update Records) - The object "GroundTravelEnrgyUse" doesn't exist. Employee_Energy_Footprint_Survey: Get_Hotel_Stay_Emissions_Factor_ID (Get Records) - The object "HotelStayEmssnFctr" doesn't exist. Hybrid_Work_Wizard_Admin_Flow: Assign_Selected_Values (Assignment) - The element has an invalid reference to "Get_HWW_Admin.Commute_Emissions_Source__c". GroundTravelEmssnFctr: Invalid fullName, must end in a custom suffix (e.g. __c) GroundTravelEnrgyUse: Invalid fullName, must end in a custom suffix (e.g. __c) HotelStayEmssnFctr: Invalid fullName, must end in a custom suffix (e.g. __c) HotelStayEnrgyUse: Invalid fullName, must end in a custom suffix (e.g. __c) Scope3CrbnFtprnt: Invalid fullName, must end in a custom suffix (e.g. __c) Employee_Energy_Use__c.Ground_Travel_Emissions_Factor__c: referenceTo value of 'GroundTravelEmssnFctr' does not resolve to a valid sObject type Employees_with_EEUs_Commute_and_Ground_Travel: No such relationship Ground_Travel_Energy_Uses__r on object Commute_Survey_Object__c Employees_with_EEUs_Commute_and_Hotel_Stay: No such relationship Hotel_Stay_Energy_Uses__r on object Commute_Survey_Object__c Employees_with_EEUs_and_Commute_Schedule: In field: field - no CustomField named Employee_Energy_Use__c.Stationary_Asset_Environmental_Source__c found Employees_with_EEUs_and_Commute_Survey: In field: field - no CustomField named Employee_Energy_Use__c.Ground_Travel_Emissions_Factor__c found Employee_Energy_Use__c.Hotel_Stay_Emissions_Factor__c: referenceTo value of 'HotelStayEmssnFctr' does not resolve to a valid sObject type Employee_Energy_Use__c.Stationary_Asset_Environmental_Source__c: referenceTo value of 'StnryAssetEnvrSrc' does not resolve to a valid sObject type Hybrid_Work_Wizard_Admin__c.Commute_Emissions_Source__c: referenceTo value of 'Scope3EmssnSrc' does not resolve to a valid sObject type

Original Question: I am trying to create a version of a 2gp unlocked package that needs access to Net Zero Cloud objects. I am able to create the initial package but I am unable to create a version due to permission issues I am assuming. At the bottom are some examples of what I am seeing. It is my understanding a scratch org actually gets created behind the scenes when a version is created and I believe this scratch org admin user needs to be assigned the NZC permission sets to create the version. I am wondering if this can be done in the project-scratch-def.json file or by some other mechanism?

Sample of errors (there are more but this is the gist of it):

GroundTravelEmssnFctr: Invalid fullName, must end in a custom suffix (e.g. __c)
GroundTravelEnrgyUse: Invalid fullName, must end in a custom suffix (e.g. __c)
Commute_Schedule_Confirmation: Update_Ground_Travel_Energy_User_Record (Update Records) - The object "GroundTravelEnrgyUse" doesn't exist.

2
  • Can I add apply my own custom permission set in this manner? I have tried adding the NZC permission I need but still get access errors (cannot update field from flow) when packaging. I just want to confirm if I can or cannot apply my own permission sets. I did get by most other errors by applying the NZC permission sets and modifying the project-scratch-config-def.json with the SustainabilityApp feature.
    – CascoSteve
    Jan 4, 2023 at 16:03
  • Hi @CascoSteve, were you able to solve your issue and create your 2GP package? If yes, could you share your solution?
    – POZ
    Mar 30, 2023 at 8:04

1 Answer 1

3

Yes, this is what apexTestAccess is for in the sfdx-project.json file.

It allows you to set permission sets and permission set licenses when running the tests for version creation.

Taking the example from that page:

"packageDirectories": [
    {
        "path": "force-app",
        "package": "TV_unl", 
        "versionName": "ver 0.1",
        "versionNumber": "0.1.0.NEXT",
        "default": true, 
        "unpackagedMetadata": {
            "path": "my-unpackaged-directory"
        },
        "apexTestAccess": {
               "permissionSets": [
                   "Permission_Set_1",
                   "Permission_Set_2"
               ],
               "permissionSetLicenses": [
                   "SalesConsoleUser"
               ]
           }

    }, 
    {
        "path": "my-unpackaged-directory",
        "default": false
    }
]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .