Enable a Package Subscriber to Restrict Push Upgrades
-
The Salesforce Partner enables customized push upgrades for a package installed in the
customer org.
- As the Salesforce Partner, log in to either your 1GP packaging org, or your Dev Hub org (for managed 2GP packages) using the system administrator account.
- Click the gear icon and select Developer Console.
- In the Developer Console, select Debug, and then select Open Execute Anonymous Window.
-
Enter the following code, but remember to replace the
packageID (starts with 033)
and subscriberOrgID (starts with 00D)
text for the package ID and customer org you’re enabling.
1String pucId1 = PushUpgradeCustomizationRepository.create('packageID', 'subscriberOrgID', true); 2System.debug('pucId1 =' + pucId1);Optionally, you can set the ability to block push upgrades to expire after a certain number of days. This example sets customized push upgrades to expire after 90 days.
1String pucId1 = PushUpgradeCustomizationRepository.create('packageID', 'subscriberOrgID', true, 90); 2System.debug('pucId1 =' + pucId1);If the customer wants to block push upgrades to multiple production orgs, you must specify each org ID. Here’s an example of how to enable customized push upgrades for more than one org.
1String pucId1 = PushUpgradeCustomizationRepository.create('packageID', 'subscriberOrgID', true); 2System.debug('pucId1 =' + pucId1); 3 4String pucId2 = PushUpgradeCustomizationRepository.create('packageID', 'subscriberOrgID', true); 5System.debug('pucId2 =' + pucId2); - Click Open Log and then click Execute.
-
Click the Debug Only checkbox and verify that the push
upgrade customization record was created.
The record looks something like: 11:09:15:814 USER_DEBUG [2]|DEBUG|pucId1 =12COK000000000B
- Contact the Salesforce Customer and let them know that customized push upgrades is enabled on your end.
-
After the Salesforce Partner enables customized push upgrades, the Salesforce Customer
blocks push upgrades from Setup in the customer org.
- As the Salesforce Customer, log in to your org.
- From Setup, enter Installed Packages in the Quick Find box, and then select Installed Packages.
- Select the package that you’ve requested to block push upgrades, and then select Block Push Upgrades.
- Verify that the Push upgrades are now blocked checkbox is selected.
Salesforce Customers can resume push upgrades at any time by selecting the Allow Push Upgrades button. While the block is enabled, package upgrades can only be installed manually.
Salesforce Partners can view and manage existing customized push upgrades by using the PushUpgradeCustomizationRepository Apex Class. If you enabled customized push upgrades for a subscriber with an expiration, you can update the expiration days by following Step 1. For Step 1d, use either the setExpirationDaysForId or setExpirationDaysForIndex method to update the expiration days. This example updates the expiration days to 100 days.
1PushUpgradeCustomizationRepository.setExpirationDaysForIndex('packageID', 'subscriberOrgID', 100);
2System.debug('Expiration days updated successfully');This example updates the expiration days for the PushUpgradeCustomization record ID 12Cxx000000ABCDEF1 to 120 days.
1PushUpgradeCustomizationRepository.setExpirationDaysForId('12Cxx000000ABCDEF1', 120);
2System.debug('Expiration days updated successfully');