Newer Version Available
PackagePushJob
Supported Calls
create(), describeSObjects(), query(), retrieve(), update(), upsert()
Special Access Rules
To initiate a push upgrade for a first-generation managed package, the Upload AppExchange Packages user permission is required.
To initiate a push upgrade for an unlocked or second-generation managed package, the Create and Update Second-Generation Packages user permission is required.
The push upgrade feature is only available to first- and second-generation managed packages that have passed AppExchange security review. To enable push upgrades for your managed package, log a support case in the Salesforce Partner Community.
For unlocked packages, push upgrades are enabled by default.
Fields
| Field Name | Details |
|---|---|
| DurationSeconds |
|
| EndTime |
|
| PackagePushRequestId |
|
| StartTime |
|
| Status |
|
| SubscriberOrganizationKey |
|
Usage
Suppose that you want to push version 3.4.6 of your package to all orgs. You���ve already identified the orgs eligible for the upgrade by using MetadataPackageVersion and created the push request using PackagePushRequest. Now let’s write some code to create a push job for each eligible org.
This code sample uses the Web Services Connector (WSC).
1PackageSubscriber[] subscribers = new PackageSubscriber[];
2
3// ... populate eligible and desired subscribers
4
5// Create the PackagePushJob array
6PackagePushJob[] jobs = new PackagePushJob[subscribers.length];
7
8for (int i = 0; i < subscribers.length; i++) {
9 // create a job for each subscriber...
10 PackagePushJob job = new PackagePushJob();
11 // ... associate it to the PackagePushRequest ppr...
12 job.setPackagePushRequestId(ppr.getId());
13 // ... and add the orgKey
14 job.setSubscriberOrganizationKey(subscribers[i].getOrgKey());
15 jobs[i] = job;
16}
17
18// Save the jobs
19SaveResult[] saveResults = conn.create(jobs);
20
21// Add the newly generated id's to the PackagePushJob objects
22for (int i = 0; i < saveResults.length; i++) {
23 if (saveResults[i].isSuccess()) {
24 jobs[i].setId(saveResults[i].getId());
25 }
26}1POST
2/services/data/v38.0/sobjects/packagepushjob/
3{
4 "PackagePushRequestId" : "0DV...",
5 "SubscriberOrganizationKey" : "00DR00..."
6}Checking the Status of a Push Job
1SELECT Id, Status FROM PackagePushJob WHERE PackagePushRequestId ='0DV...'1// Finds the status of the PackagePushJob with the given id
2String PACKAGE_PUSH_JOB_STATUS_QUERY = "Select status from PackagePushJob where Id = '%s'";
3
4// job is a PackagePushJob instance
5QueryResult queryResult = conn.query(String.format(PACKAGE_PUSH_JOB_STATUS_QUERY,
6job.getId()));
7
8// extract the status from the QueryResult
9String status = ((PackagePushJob) queryResult.getRecords()[0]).getStatus();
10
11// optionally, update the PackagePushJob instance with the latest status
12job.setStatus(status);1// The set of states that indicate a PackagePushJob has completed
2final Set<String> TERMINAL_STATES = new HashSet<>();
3TERMINAL_STATES.add("Succeeded");
4TERMINAL_STATES.add("Failed");
5TERMINAL_STATES.add("Canceled");
6
7String status = queryJobStatus(job); // this method returns the status as retrieved in the previous code sample
8
9// If the status is not one of the completed statuses...
10while(!TERMINAL_STATES.contains(status)) {
11 Thread.sleep(10 * 1000); // ... wait 10 seconds and try again
12 status = queryJobStatus(job);
13}