BPM, Workflow, and Case

 View Only
Expand all | Collapse all

Is it possible to delete Documents attached to process instances?

  • 1.  Is it possible to delete Documents attached to process instances?

    Posted Sun May 16, 2021 07:41 AM

    When using embedded BPM document store, is there some administrative script or API to cleanup documents attached to instances?
    The requirement is to delete documents attached to old completed instances for regulatory compliance, but without deleting the instances itself, that are still needed for performance dashboards.

    Any good practice around is welcome.

    I guess that right answer is to use an external ECM to leverage full document lifecycle management independently of the process instances lifecycle, but in this case the client is using internal BAW doc store.



    ------------------------------
    Eduardo Izquierdo Lázaro
    Automation Architect
    DECIDE
    ------------------------------


  • 2.  RE: Is it possible to delete Documents attached to process instances?

    Posted Mon May 17, 2021 06:02 AM
    The best solution for this problem would probably be to remove the documents in a system lane activity as the very last step of the process instance. There are at least 3 ways to do that:
    1. Loop over each entry in tw.system.currentProcessInstance.documents and delete via the TWDocument.deleteAllVersions() API call.
    2. Use the CMIS operations in the 'Content Integration Task' from a service flow to first retrieve all of the documents using the 'Search' method and looking for documents matching the current process instance ID, then loop over each returned document and issue the 'Delete document' call from another 'Content Integration Task'.
    3. Using the REST API, obtain the process instance details via /rest/bpm/wle/v1/process/[processInstanceId] - the response contains data.documents and this can be looped over and the REST API call to delete an instance document can be called via a POST /rest/bpm/wle/v1/process/[processInstanceId]?action=deleteDocument&docId=[documentId]
    If adding a step to the process cannot be done, then some sort of polling (i.e. time-based UCA) mechanism could be used to check for completed or terminated instances on a scheduled basis, then loop over any documents associated with the instance and delete them. Querying all completed or terminated instances using TWSearch or the REST API could get expensive over time depending on the volume of process instances, so it is advisable to also track whether or not a process instance's documents have been cleaned up. If a system of record is available, tracking whether or not the process instance's documents have been cleaned up would be pretty straightforward. Without an external way to track this, there might be a way to query completed or terminated instances whose last modified date is within the past 24 hours, for example, and only process those. That would at least limit the instances being processed in a single scheduled cleanup job to just those completed within the past day. Increasing the interval to 48 hours or even 7 days might be a little safer in case jobs don't run due to scheduled maintenance or some other unexpected issue.

    Hope that helps you get pointed in the right direction! Thanks -Don

    ------------------------------
    Don Williams
    ------------------------------



  • 3.  RE: Is it possible to delete Documents attached to process instances?

    Posted Mon May 17, 2021 12:29 PM

    Many thanks Don, that is exactly what I was looking for.

    Just one more question or comment.

    Before asking the forums, I spent quite a long time trying to find a REST API like the one you sent. Still, after knowing the answer, I cannot find any documentation for the action "deleteDocument" with a parameter "docId" in the reference documentation of the product (https://www.ibm.com/docs/en/baw/20.x?topic=apis-process-rest-reference).

    If no documented, how may I know that I should provide those params in the query string? Is it maybe that I'm not searching in the right place?
    where can I find a proper user and/or reference documentation for BAW APIs?

     



    ------------------------------
    Eduardo Izquierdo Lázaro
    Automation Architect
    DECIDE
    ------------------------------