PackagePushRequest
サポートされているコール
create()、describeSObjects()、query()、retrieve()、update()、upsert()
項目
| 項目名 | 詳細 |
|---|---|
| PackageVersionId |
|
| ScheduledStartTime |
|
| Status |
|
使用方法
パッケージのバージョン 3.4.6 をすべての組織に転送するとします。MetadataPackageVersion を使用して、アップグレード対象の組織をすでに特定しています。各対象組織の転送ジョブを保持する転送要求を作成するため、いくつかのコードを記述しましょう。
このサンプルコードでは、Force.com Web Services Connector (WSC) を使用しています。
1// Create a new PackagePushRequest for the versionId to upgrade to
2// (for example, versionId is the "04t..." id of version
3// 3.4.6 of the package
4PackagePushRequest ppr = new PackagePushRequest();
5ppr.setPackageVersionId(versionId);
6
7// Optionally, set the start time of the PackagePushRequest to schedule it to begin
8// automatically; scheduledStartTime is a java.util.Calendar instance
9ppr.setScheduledStartTime(scheduledStartTime);
10
11// Save the PackagePushRequest
12SaveResult[] saveResults = conn.create(new SObject[] { ppr });
13if (saveResults[0].isSuccess()) {
14 // Add the newly generated Id to the object
15 ppr.setId(saveResults[0].getId());
16} else {
17 for (Error error : saveResults[0].getErrors()) {
18 System.out.println(error.getMessage());
19 }
20}または、REST API を使用している場合、次の例のように POST 要求を PackagePushRequest sObject エンドポイントに送信します。SOAP API もサポートされています。
1POST
2/services/data/v38.0/sobjects/packagepushrequest/
3{
4 "PackageVersionId" : "04t...",
5 "ScheduledStartTime" : "2016-08-24T21:00:00"
6}次のステップでは、PackagePushJob を使用して、アップグレードする各対象登録者の転送ジョブを作成します。
転送アップグレードのスケジュール
転送アップグレードの準備ができていることを示すには、転送要求の状況を Pending に変更します。ScheduledStartTime を設定していない場合、転送アップグレードは状況を変更した直後に開始されます。
1// ppr is the PackagePushRequest instance
2ppr.setStatus("Pending");
3conn.update(new SObject[] { ppr });REST API を使用している場合、次の例のように PATCH 要求を PackagePushRequest sObject エンドポイントに送信します。SOAP API もサポートされています。
1PATCH
2/services/data/v38.0/sobjects/packagepushrequest/0DV...
3{
4 "Status" : "Pending"
5}転送要求の状況の確認
1// Finds the status of the PackagePushRequest for a given Id
2final String PACKAGE_PUSH_REQUEST_STATUS_QUERY = "Select status from PackagePushRequest" +
3 " where Id = '%s'";
4
5// ppr is a PackagePushRequest instance
6QueryResult queryResult = conn.query(String.format(PACKAGE_PUSH_REQUEST_STATUS_QUERY,
7 ppr.getId()));
8
9// extract the status from the QueryResult
10String status = ((PackagePushRequest) queryResult.getRecords()[0]).getStatus();
11
12// optionally, update the PackagePushRequest instance with the latest status
13ppr.setStatus(status);PackagePushJob の Status 項目をクエリしてジョブの状況を確認することもできます。
転送要求の中止
状況を [Canceled] に変更して、パッケージ転送要求を中止できます。
1PATCH
2/services/data/v38.0/sobjects/packagepushrequest/0DV...
3{
4 "Status" : "Canceled"
5}1// ppr is the PackagePushRequest instance
2ppr.setStatus("Canceled");状況が [Created] または [Pending] の場合のみパッケージ転送要求を中止できます。中止が成功すると、関連する転送ジョブもすべてキャンセルされます。現在の PackagePushRequest の状況が [Canceled]、[Succeeded]、[Failed]、または [In Progress] の場合、転送は中止されずにエラーメッセージが返されます。