AX workflow history clean up

Hi All,

Let me post another query regarding with AX2009 workflow. Is there anyway to clean up the workflow history? We are not sure how many tables we have to look at.

We are reluctant to do that because we are having a lot of workflow error (deadlock, fail to find workflow, duplicate workflow steps, etc). So, we are afraid that deleting records from workflow table would make more orphanage records in WorkflowMessageTable.

If you have any idea or experience, kindly share as we are facing the same issue everyday with our AX09 clients.

thanks.

Regards,

Yuan

Test the below script with limited lines and proceed if it works.

delete_from WorkflowTrackingStatusTable

where WorkflowTrackingStatusTable.TrackingStatus ==

WorkflowTrackingStatus::Completed &&

WorkflowTrackingStatusTable.WorkflowType ==

WorkflowTrackingStatusWorkflowType::Workflow &&

WorkflowTrackingStatusTable.modifiedDateTime <

DateTimeUtil::addMonths(DateTimeUtil::utcNow(),-3);

delete_from WorkflowTrackingStatusTable

where WorkflowTrackingStatusTable.TrackingStatus ==

WorkflowTrackingStatus::Cancelled &&

WorkflowTrackingStatusTable.WorkflowType ==

WorkflowTrackingStatusWorkflowType::Workflow &&

WorkflowTrackingStatusTable.modifiedDateTime <

DateTimeUtil::addMonths(DateTimeUtil::utcNow(),-3);