Skip to main content
In Pega, a single Service REST can contain both a POST method and a DELETE method.

Add the DELETE method

1

Open the existing Service REST

Click Records → Integration-Services → Service REST and select cases/{id}/files/{name}, the service you created earlier. Then open the Methods tab.For more information, see Create a Service REST method.
2

Open the DELETE response settings

Expand the DELETE method and open the Response tab.
3

Create the response conditions

Create three conditions identical to the conditions you created for the POST method. For more information, see Response conditions.

Create the DeleteFiles activity

1

Name the activity

In the Activity name field, type DeleteFiles. Click the target icon on the right, and then click Create and open on the Create Property form.
2

Declare the page

On the Pages & Classes tab, create a new page named pyWorkPage of the Work- class.
3

Create the variables

On the Parameters tab, create three variables:
  • currentLinkedRefTo of type String
  • IsConverted of type Boolean
  • currentFileId of type String
4

Open and load the case

On the Steps tab, open and load your case into the pyWorkPage page using the Obj-Open-By-Handle method.Use the Param.CaseId parameter as the case identifier. This parameter can be taken from the /cases/{id}/files/{name} request.
5

Loop over the case attachments

  1. Type Property-Set in the Method field.
  2. Open Loop, select For each element in value list, and type pyWorkPage.pyAttachments in the Value List Property field.
  3. Add the following two new parameters to the method:
6

Call the DeleteAttachment activity

Create a Call DeleteAttachment activity call and specify pyWorkPage in the Target field. Set the WorkPageName parameter to Local.currentLinkedRefTo and the LinkHandle parameter to Local.currentFileId.
7

Add the deletion condition

In the When field, specify the following condition: if Param.FileName = pyWorkPage.pyAttachments(<CURRENT>).pyFileName, delete the files, and otherwise skip this step.