1

Have read about limitations that package settings (such as in a PostInstall Apex class) for second generation managed packages (like this one Is it possible to programmatically change connectedApp settings in production?).

To get around that, can I define a Lightning App with a Lightning Tab that loads an LWC containing a Setup Assistant for the System Administrator with documentation and buttons that would perform tasks (via Apex) such as:

  1. Create an integration user based on least privilege
  @AuraEnabled
  public static void createIntegrationUser(String profileName){
    try {
      Profile integrationProfile;
      try {
        integrationProfile = [SELECT Id FROM Profile WHERE Name = :profileName LIMIT 1];
      } catch (QueryException e) {
        System.debug('Profile not found: ' + e.getMessage());
        return;
      }

      ConnectApi.OrganizationSettings orgSettings = ConnectApi.Organization.getSettings();

      User newUser = new User(
        Username = orgSettings.orgId + '[email protected]',
        Email = '[email protected]',
        Alias = 'Example',
        ProfileId = integrationProfile.Id,
        LastName = 'Integration User',
        FirstName = 'Example',
        TimeZoneSidKey = 'America/New_York',
        LocaleSidKey = 'en_US',
        EmailEncodingKey = 'UTF-8',
        LanguageLocaleKey = 'en_US'
      );

      insert newUser;

    } catch (Exception e) {
      System.Debug(e.getMessage());
    }
  }
  1. Activate Change Data Capture for Opportunities
  2. Configure our Managed Package's Connected App to isAdminApproved to true
  3. Add profiles to the Managed Package's Connected App

The idea would be to give the Administrator documentation to say, "Click the Apps button then type My Company Setup".

1
  • In a word: yes. Doesn't mean there is anything you can set to make this available, since a post install URL cannot point to a lightning page. You will need to document what you want the admin to do...
    – Phil W
    Commented Dec 31, 2023 at 19:09

0

You must log in to answer this question.

Browse other questions tagged .