5

I am trying to create a 2GP that includes an Aura component, which shows a canvas app using force:canvasApp.

I have tested this Aura component by creating it in the developer console. I did this in the organisation where I have a connected app, which is referenced by its developer name. This approach works in the 1GP.

However, I am running into trouble while trying to achieve the same result in a 2GP. I have created a scratch org from my PBO (also my Dev Hub). Then I created a managed package in this scratch org. This all according to this workflow. The project has roughly the following structure:

config
  | project-scratch-def.json
force-app/main/default
  | aura
    | CanvasApp
      | App.cmp
      | App.design
      | App.svg
      | AppController.js
  | staticresources
      | canvasStatic.js
      | canvasStatic.resource-meta.xml 
  sfdx-project.json

The App.cmp file references the Connected App like this:

<force:canvasApp applicationName="Some Name" developerName="<namespace>__<developername>" />

Where the namespace is the namespace of the previously mentioned 1G package, and the developer name is the name of the Connected App in that package. The namespace of the 1G package is linked to my PBO (Dev Hub), thus the scratch org has the same namespace.

When I create a version for this package, it installs successfully, but when I load the page it reports this message:

Your browsing session has ended or is invalid. Please re-login to Salesforce.com again.

I have tried generating a password for the user account as suggested here, but that did not help. I found this article from SFDX Developer Guides, but I do not understand steps 4 and 6. Following these instructions actually caused different problems. I added the .xml file as suggested, after which creating the package version would give the following error:

: Installing an app (App Name) that has been deleted.

I also could not install the 1GP package into the scratch org, as they have the same namespace:

  1. Package(Package ID) Package and subscriber org namespace collision, Details: The installing package namespace and org namespace cannot be the same.

Can anybody tell me how to show a connected app using force:canvasApp in a 2GP?

1
  • 1
    Welcome to Salesforce Stack Exchange (SFSE). Unfortunately this is out of my current realm of expertise. Hopefully someone with knowledge in that area will come along soon to help. I just wanted to thank you for such a well written question, and for including code and text of exact error messages. That is refreshing for a first-time poster. I hope to see many future contributions to SFSE.
    – Moonpie
    Aug 31, 2021 at 14:29

1 Answer 1

3

You can't have a 1GP and 2GP by the same namespace in the same org, which explains your last problem.

The directions you linked to presume that the Connected App is in a 1GP, that the 1GP has been previously uploaded in a Released state, and you're trying to create a 2GP.

Given the above, your source directory is missing the /connectedApps/<namespace>__<developerName>.connectedApp-meta.xml file, which you need in order to use the Connected App.

The source for the file can be retrieved from the original 1GP packaging org (not the PBO/Dev Hub). The 1GP does not need to be installed to use the Connected App.

You can probably just fix this with the following command:

sfdx force:source:retrieve -m ConnectedApp -u packaging-org

This will give you the correct file you need to complete this setup.

2
  • Thank you for your answer. I retrieved the source for the ConnectedApp I wish to use successfully. However, I now receive an unexpected error: ERROR running force:package:version:create: <App Name>: An unexpected error occurred. Please include this ErrorId if you contact support: 1873642432-1237618 (-711163783) I already contacted support, is there any place I can see a list for these error codes? Aug 31, 2021 at 16:06
  • 1
    @RinkStiekema See What is a Gack?, but basically, no, you can't see these, they are internal to Salesforce Employees.
    – sfdcfox
    Aug 31, 2021 at 16:10

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.