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:
currentLinkedRefToof typeStringIsConvertedof typeBooleancurrentFileIdof typeString
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
- Type
Property-Setin the Method field. - Open Loop, select For each element in value list, and type
pyWorkPage.pyAttachmentsin the Value List Property field. - 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.