Yesterday I face a problem; some Ledger journal records are stuck into Workflow. In Error message, described about issues in customization. In the after last deployment code full cil was not generated. So first step is full Cil generation.
For resubmit these pending records, I used the code snippet delivered on Microsoft Forum by Dick wenning. It help me to resolve ledgers records.
https://community.dynamics.com/ax/f/33/t/77311
WorkflowTrackingStatusTable WorkflowTrackingStatusTable;
while select WorkflowTrackingStatusTable where WorkflowTrackingStatusTable.TrackingStatus == WorkflowTrackingStatus::Faulted &&
WorkflowTrackingStatusTable.WorkflowType == WorkflowTrackingStatusWorkflowType::Workflow
{
Workflow::resumeWorkflow(WorkflowTrackingStatusTable.CorrelationId);
}
I updated the code snippet based on reci id instead of all faulted records.
WorkflowTrackingStatusTable WorkflowTrackingStatusTable;
select * from WorkflowTrackingStatusTable where WorkflowTrackingStatusTable.RecId ==5637166344;
if (WorkflowTrackingStatusTable!=null)
{
Workflow::resumeWorkflow(WorkflowTrackingStatusTable.CorrelationId);
}
You can get recid from workflow history screen.
But one record remains unrecoverable. For this I explored tables as follow.
If we explore workflow tables, you find that main player tables are
SysWorkflowTable
WorkflowTrackingStatusTable
WorkflowTrackingTable
In workflowTrackingStatusTable ContexttableId feild contains the table id of ledgerjournaltable and contextrecid contains the records recid of ledgerjoural row on workflow is applied.
SysWorkflowTable correlation id is key relation between Sysworkflow.
In current scenario, when all records are recovered, but one record is not recoverable. The follow these steps, but you can use them but your own risk.
- Get recid from workflowTrackstatusTable from workflow history. Or Use contextrecid of LedgerJournalTable.
- Sql Query on workflowtrackingSTatusTable and get correlationId.
- Query on SysworkflowTable workflowcorrelationid and get the reference sysworkflow table and get reference id
- Query on Select WorkflowTrackingTable workflowTrackingTable.WORKFLOWTRACKINGSTATUSTABLE Which is based on recid of workflowTrackStatusTable.
- Delete the records based on reference and reset the ledgerJournaltable status to draft.
For your reference I used following Select query.
select from WorkflowTrackingStatusTable where CONTEXTRECID =5637239972
select * from WorkflowTrackingTable where WorkflowTrackingTable.WORKFLOWTRACKINGSTATUSTABLE =5637166344
select * from SysWorkflowTable where workflowcorrelationid =’D4AF23DF-9CC1-40F9-B886-DAB1CD6B35DE’
update LEDGERJOURNALTABLE set WORKFLOWAPPROVALSTATUS=1 where lEDGERJOURNALTABLE.JOURNALNUM =’xyze’