I want to delete a file that was already attached to a case, so that I can attach another file with the same name to the case.I’m having trouble doing it properly, so I’d like to consult on a solution.
We have implemented the following steps:
Attach a file to the case using OOTB
Call Code-Pega-PDF.AttachToWork
Use the following OOTB parameters:
PDFDocument: the file information in byte array format
PDFName: the file name
InsHandle: pzInsKey
Delete the file attached in step (1) (zip file)
Identify the target file for deletion (loop process)
Hi @SachikaO: Thanks for detailed explanation of the issue.
eThere can be chances that a instance of Data-WorkAttach-File can be associated with multiple cases (multiple instance in “Link-Attachment”). If you are sure and if you want to delete from Data-WorkAttach-File too, please set “TempAttachmentPage.pyStatusValue” value as “SingleRef”. This is generally taken care by Work- DeleteAttachment.
@SachikaO you can either use the method which Arun mentioned or you can do obj-deleteby-handle using activity too. As you have the pzinsky of both link- and Data-work-attachfile. You can get the pzinskey of that particular attachment Link- key, obj-delete-by-handle. Then Data-work-attachfile key, obj-delete-by-handle.
By calling pyCheckAttachmentLinks before calling OOTB pyDeleteAttachment, I was able to confirm that the file was deleted from Data-WorkAttach-File as well. Thanks for your help.