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:
- 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());
}
}
- Activate Change Data Capture for Opportunities
- Configure our Managed Package's Connected App to isAdminApproved to true
- 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".