Process for deleting files in Data-WorkAttach-File

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:

  1. 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
  2. Delete the file attached in step (1) (zip file)
    • Identify the target file for deletion (loop process)
      • D_AttachmentList[LinkRefFrom:pyWorkPage.pzInsKey,IncludeDocAttachments:param.AttachmentCategory].pxResults
    • Use OOTB to delete the identified file
      • Call pyDeleteAttachment

The result of the process is as follows:

  1. The file disappears from the case screen.
  2. The file remains in Data-WorkAttach-File.(No errors have occurred.)

We want to remove the file from Data-WorkAttach-File as well.

I tried using this as a reference, but it didn’t work out.

I tried the following processes as well, but they didn’t work out: pzPreRMAction, PostActionDelete, and pzRemoveAttachment.

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.

Some more (other) details you can see here

Thanks.

@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.

@SachikaO

In the loop Call pyCheckAttachmentLinks before calling pyDeleteAttachment

pyCheckAttachmentLinks OOTB activity will take care of setting required pages like TempAttachmentPage.pyStatusValue

Your steps would be

Loop D_AttachmentList

Call pyCheckAttachmentLinks

Call pyDeleteAttachment

Let me know if this helps.

@abhirajg @Anoop Krishna @ArulDevan

Thanks for your response.

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.

Hi @SachikaO

Implemented the same way but writing the Activity in the Work class but it deleting the fie with Fail message Eg : Harness failed.

Passing required parameters before the loop

I’m getting the fail in clipboard and parameters are not passing expecting the pyStreamName , even if it is harcording it

Can you suggest another approach.

Thanks