Wednesday, January 31, 2018

Workflow Batch Error: "Failed to find workflow"

Resolution:

Note: Before running in any AX environment, Take backup of table and data from SQL for the table(SYSWORKFLOWMESSAGETABLE)

Code snippet:

static void San_WkfjobError(Args _args)
{
    SysWorkflowMessageTable sysWorkflowMessageTable;
    SysWorkflowTable sysWorkflowTable;
    ;
    ttsBegin;
    while Select forupdate sysWorkflowMessageTable
        Where sysWorkflowMessageTable.MESSAGELIFECYCLESTATE == 1 
            && sysWorkflowMessageTable.ROOTCORRELATIONID
        notexists join sysWorkflowTable
            where sysWorkflowTable.RootCorrelationId == sysWorkflowMessageTable.RootCorrelationId
    {
        info(strFmt("%1,%2",sysWorkflowMessageTable.RecId,sysWorkflowMessageTable.AssignedUser));
        sysWorkflowMessageTable.MESSAGELIFECYCLESTATE = 2;
        sysWorkflowMessageTable.update();
    }
    ttsCommit;
}

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...