

Sudipta Deb
Founder of Technical Potpourri, Co-Founder of Shrey Tech, Enterprise Cloud Architect
In the dynamic world of Salesforce, managed packages offer a robust way to distribute and manage custom applications and components across multiple Salesforce organizations. However, once a managed package is installed, understanding the nuances of its integration can be crucial for maintaining system integrity and ensuring optimal performance. This blog post will delve into two key aspects of managed package management: checking the installation details and exploring the associated data model.
One of the primary tasks after installing a managed package is verifying which user profiles have access to it. This includes determining which profiles the package is installed for and which ones are excluded. This verification process is essential for ensuring that the right users have the necessary permissions and that your organization's security policies are upheld.
Equally important is understanding the data model that comes with the managed package. Each managed package often includes custom objects, fields, and relationships that integrate with your existing Salesforce data. By exploring the data model, you can gain insights into how the package's components interact with your data, enabling you to optimize its use and troubleshoot any issues that may arise.
The form you have selected does not exist.
Exploring The Data Model
The PackageInstallRequest object in Salesforce is used to manage and track the installation of packages, particularly managed packages, within a Salesforce organization. This object allows administrators and developers to automate the installation process and monitor its progress programmatically. Below are some key aspects and fields associated with the PackageInstallRequest object:
Key Features of the PackageInstallRequest Object
- Automation of Package Installation: Instead of manually installing packages through the Salesforce UI, the
PackageInstallRequestobject lets you initiate and manage installations through Apex code or the Metadata API. - Tracking Installation Status: By querying the
PackageInstallRequestobject, you can monitor the status of a package installation, check for errors, and get details about the installation process. - Configuration Options: The object allows you to set various options for the installation process, such as security settings and upgrade behaviors.
Important Fields in the PackageInstallRequest Object
Here are some key fields you might use with the
PackageInstallRequestobject:- Id: The unique identifier for the
PackageInstallRequestrecord. - Status: Indicates the current status of the installation request (e.g.,
InProgress,Success,Error, Unknown). - SubscriberPackageVersionKey: The unique identifier for the package version being installed.
- ApexCompileType: For unlocked package installs and upgrades, specifies whether to require successful compilation of all Apex in the org, or only Apex within the package. Valid values are: all or package.
- EnableRss: Boolean flag indicating whether the package can send and receive Remote Site Settings (RSS) and Content Security Policy (CSP) data from third-party websites (true) or not (false). The default value is false.
- UpgradeType: Specifies the type of upgrade to be performed (e.g., delete-only, deprecate-only, mixed-mode).
- SecurityType: Specifies the users for which this package is installed (e.g., Custom - Installed for specific custom profiles, Full - Installed for All Users, None - Installed for Administrators only).
- Errors: Contains information about any errors that occurred during the installation process.
- Id: The unique identifier for the
Example Usage
Here’s an example of how you might use the PackageInstallRequest object in Apex to initiate a package installation:
// Create a new PackageInstallRequest
PackageInstallRequest installRequest = new PackageInstallRequest();
installRequest.SubscriberPackageVersionKey = '04t...'; // The package version key
installRequest.Password = 'YourPackagePassword'; // If the package is password-protected
installRequest.EnableRss = true; // Optional: enable sharing rules for the managed package
// Insert the request to initiate the installation
insert installRequest;
// Check the status of the request
PackageInstallRequest requestStatus = [SELECT Status, Errors FROM PackageInstallRequest WHERE Id = :installRequest.Id];
if (requestStatus.Status == 'SUCCESS') {
System.debug('Package installed successfully.');
} else if (requestStatus.Status == 'ERROR') {
System.debug('Package installation failed with errors: ' + requestStatus.Errors);
}Monitoring Installation Status
After initiating the installation, you can monitor the status by querying the PackageInstallRequest object. This is particularly useful for long-running installations where you need to check back periodically to ensure everything completed successfully.
// Query the installation request status
List<PackageInstallRequest> installRequests = [SELECT Id, Status, Errors FROM PackageInstallRequest WHERE Status = 'IN_PROGRESS'];
for (PackageInstallRequest req : installRequests) {
System.debug('Package installation in progress: ' + req.Id);
}Checking The Managed Pacakage Installation Details
You need to execute Tooling API Query to get the details about a package installation. Here is one example, where CPQ package is installed in one of my production org.

As you can see that this package was installed on 5/15/2024 at 9:54 AM. So now if I wanted to know the details about this installation, all I need to do is execute Tooling API query.
To execute that, I will open the workbench in another tab (https://workbench.developerforce.com/login.php). Once logged in, I will go to Utilies -> REST Explorer. Here, I will select HTTP Method as GET and execute the below query:
/services/data/v58.0/tooling/query/?q=select+ApexCompileType,ProfileMappings,SecurityType,CreatedDate,PackageInstallSource,SubscriberPackageVersionKey,UpgradeType+from+PackageInstallRequest
This will bring all the PackageInstallRequest details from the org. I will open the one where the installion date and time will match. So here is what I am getting for my CPQ installation package.

As you can see from the above image, CreatedDate matches, so this is for my CPQ installation. SecurityType is Custom, which means CPQ package is installed for specific custom profiles. So this is the way you can get details about the package installation request.
Conclusion
The PackageInstallRequest object is a powerful tool for automating and managing package installations in Salesforce. By leveraging this object, you can streamline your deployment processes, ensure consistency across environments, and quickly identify and resolve installation issues.
Disclaimer
This article is not endorsed by Salesforce, Google, or any other company in any way. I shared my knowledge on this topic in this blog post. Please always refer to Official Documentation for the latest information.



0 Comments