Expiring TaskResults after Workflow Execution

  • 7011085
  • 20-Oct-2011
  • 19-Oct-2012

Resolution

During the execution of workflows in Access Governance Suite task result objects are created and persisted in the database.  You can view the results from the Monitor -> Tasks -> Task Results page.  It is a best practice to define the expiration time for these Task Results in your workflows.   When the expiration time has been met the Maintenace task will delete the results.

You can define an overall default in your workflow using the resultExpiration attribute:

<Workflow explicitTransitions="true" name="My Custom Leaver Process"
type="IdentityLifecycle" resultExpiration="5"> <!-- Stay around for 5 days after completion -->

The following notes explain what values are expected.

    /**
     * Specifies the length of time the task results for this process
     * are kept before being deleted.
     *
     * If the value is zero the results do not expire.  If the number
     * is positive, the unit is days.  If the number is -1 it means
     * the result expires immediately.  If the number is less than -2
     * the number is made positive and treated as a number of seconds.
     *
     * Note that you can add a step to modify this value as the case
     * runs in case you need more control over the task result based
     * what happened, for example expiring immediately unless there
     * are error messages.
     */

In your workflow logic you can also override the default value during the workflow execution.  The benefit of setting the value at runtime is that you can choose to cleanup the results immediately if there were no errors or error conditions in the workflow.   Using the WorkflowContext you can get the TaskResult and set the expiration to today's date.  This will effectively cause the TaskResult to be cleaned up immediately (when the maintenance task runs).

<Step name="Remove Task Results"><Script><Source> 
//Check for any errors first 
TaskResult result = wfcontext.getTaskResult();
result.setExpiration(new java.util.Date());</Source></Script>
....</Step>