workflow 4 - archiving instances RRS feed

  • Question

  • Hello All,

    Is there a preferred way of archiving workflow instances that are compete? I would like to move records from InstancesTable, InstancePromotedPropertiesTable to similar structured archive tables upon instance completion.

    My first thought was to set instanceCompletionAction to "DeleteAll", and tweak DeleteInstance stored procedure (of the persistence service block) to copy records for a given @surrogateInstanceId to the archived area. Unfortunately, SaveInstance stored procedure, that takes @isCompleted argument and resolves @deleteInstanceOnCompletion (in this case to true) to then call DeleteInstance (when @isCompleted = true), has no @executionStatus set. So the copied records would still show ExecutionStatus = 'Executing' and not 'Closed' or 'Faulted', which doesn't help.

    The second thought was to set instanceCompletionAction to "DeleteNothing" and move records to the archives when IsCompleted bit is set to true. However, I couldn't find a good spot to weave in the archiving steps. I did consider tweaking SaveInstance proc, but I didn't want to mess up with locks or other built-in hidden logic. I made an attempt to find something like OnClosed event in my workflow, so I could handle the archiving then, but I wasn't successful.

    Thanks in advance,


    Tuesday, June 8, 2010 2:29 PM


  • Hi Andrei,

    do you have the instances being archived right away? If not, you can set instanceCompletionAction to "DeleteNothing" and create a job that periodically queryies the instance table for instances with ExecutionStatus = 'Completed', archives those instances and then removes them from the persistence store.

    Regards, Ruppert

    • Marked as answer by Andrew_Zhu Tuesday, June 15, 2010 3:19 AM
    Wednesday, June 9, 2010 6:33 PM