> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ファイル用のDELETEメソッドの作成

> Pega Service REST に DELETE メソッドと、ファイル名と case ID の照合により case からファイル添付を削除する DeleteFiles Activity を追加します。

Pega では、POST メソッドと DELETE メソッドの両方を含む Service REST を作成できます。DELETE メソッドを作成するには、次の手順を実行します。

1. **Records → Integration-Services → Service REST → cases/\{id}/files/\{name}** をクリックして、前に作成した [POST method](/ja/flexi-capture/connectors/pega/pega-create-app-web-api) を開き、**Methods** タブを開きます。
2. DELETE メソッドを展開し、**Response** タブを開きます。
3. [POST method](/ja/flexi-capture/connectors/pega/pega-create-app-web-api#response) の **Response conditions** タブで作成したものと同じ条件を 3 つ作成します。

次に、*DeleteFiles* という名前の Activity を作成する必要があります。

1. **Activity name** field に *DeteleFiles* と入力し、右側のターゲットアイコンをクリックして、**Create Property** form で **Create and open** をクリックします。
2. **Pages & Classes** タブで、*Work-* class の *pyWorkPage* という名前の新しいページを作成します。
3. **Parameters** タブで、次の 3 つの変数を作成します。
   * 型 *String* の currentLinkedRefTo
   * 型 *Boolean* の IsConverted
   * 型 *String* の currentFileId
4. **Steps** タブで、次の手順を実行します。
   1. *Obj-Open-By-Handle* メソッドを使用して、case を **pyWorkPage** ページで開いてロードします。case identifier として *Param.CaseId* parameter を使用します (この parameter は */cases/****\{id}**\*\*/files/\{name}* request から取得できます) 。
   2. case attachment からすべてのファイルを削除します。これを行うには、**Method** field に *Property-Set* と入力し、**Loop** を開いて **For each element in value list** を選択し、**Value List Property** field に *pyWorkPage.pyAttachments* と入力します。次に、このメソッドに以下の 2 つの新しい parameter を追加します。
      *Local.currentLinkedRefTo – pyWorkPage.pyAttachments(\<CURRENT>).pxLinkedRefTo;*
      *Local.currentFileId – pyWorkPage.pyAttachments(\<CURRENT>).pzInsKey;*
   3. *Call DeleteAttachment* Activity call を作成し、**Target** field に *pyWorkPage* を指定します。*WorkPageName* parameter を *Local.currentLinkedRefTo* に、*LinkHandle* parameter を *Local.currentFileId* に設定します。
   4. **When** field に次の条件を指定します。*Param.FileName = pyWorkPage.pyAttachments(\<CURRENT>).pyFileName* の場合はファイルを削除し、それ以外の場合はこの Step をスキップします。
