- Open the previously created POST method by clicking Records → Integration-Services → Service REST → cases/{id}/files/{name} and then open the Methods tab.
- Expand the DELETE method and open the Response tab.
- Create three conditions identical to the conditions you created on the Response conditions tab of the POST method.
- In the Activity name field, type DeteleFiles, then click the target icon on the right, and then click Create and open on the Create Property form.
- On the Pages & Classes tab, create a new page named pyWorkPage of the Work- class.
- On the Parameters tab, create three variables:
- currentLinkedRefTo of type String
- IsConverted of type Boolean
- currentFileId of type String
- On the Steps tab, complete the following steps:
- Open and load your case into the pyWorkPage page using the Obj-Open-By-Handle method. Use Param.CaseId parameter as the case identifier (this parameter can be taken from the /cases/{id}**/files/{name} request).
- Delete all files from the case attachment. To do this, type Property-Set in the Method field, then open Loop, select For each element in value list, and type pyWorkPage.pyAttachments in the Value List Property field. Add the following two new parameters to the method:
Local.currentLinkedRefTo – pyWorkPage.pyAttachments(<CURRENT>).pxLinkedRefTo;
Local.currentFileId – pyWorkPage.pyAttachments(<CURRENT>).pzInsKey; - Create a Call DeleteAttachment activity call and in the Target field and specify pyWorkPage. Set the WorkPageName parameter to Local.currentLinkedRefTo and the LinkHandle parameter to Local.currentFileId.
- In the When field, specify the following condition: if Param.FileName = pyWorkPage.pyAttachments(<CURRENT>).pyFileName, delete the files; otherwise, skip this step.
