Translate

Tuesday, November 12, 2019

AX Pending workflows using X++

Below is the X++ code to get the active pending workflows which are waiting for approvals and yet to approve.

workflowTrackingStatusTable is the header table which holds information about the order and the order which triggered the workflow and the current status of the workflow approvals.

workflowworkitemTable is the table which holds the information about who are all users are required to action the workflow for the particular workflow instance, once the approvee actioned then record will be deleted from this table and new approver is added to this table with new record.

workflowtrackingcommenttable will holds the comments of the user who has submitted, approved,rejected.

while select /*firstOnly10*/ workflowTrackingStatusTable //order by workflowworkitemTable.createdDateTime asc
            where workflowTrackingStatusTable.TrackingStatus == WorkflowTrackingStatus::Pending
            //&& workflowTrackingStatusTable.InstanceNumber=='INS2367227'
            //TODO: for testing- commet it in LIVE
            && (workflowTrackingStatusTable.ContextTableId == 1425//Supplier Invoice
            || workflowTrackingStatusTable.ContextTableId == 1967//Sales quotations
            || workflowTrackingStatusTable.ContextTableId == 345//Purchase order
            || workflowTrackingStatusTable.ContextTableId == 1551//Purchase requisitions
            || workflowTrackingStatusTable.ContextTableId == 617//Invoice proposals
            || workflowTrackingStatusTable.ContextTableId == 484//Travel expense claims
            || workflowTrackingStatusTable.ContextTableId == 4627) //Timesheet
            && workflowTrackingStatusTable.ContextCompanyId != "01"
            && (((workflowTrackingStatusTable.ContextTableId != 1551 && workflowTrackingStatusTable.ContextTableId != 484) && workflowTrackingStatusTable.ContextCompanyId != strMin())
                || (workflowTrackingStatusTable.ContextTableId == 1551 || workflowTrackingStatusTable.ContextTableId == 484))
            && workflowTrackingStatusTable.ContextRecId != 0
            && workflowTrackingStatusTable.ContextTableId != 0
            join workflowworkitemTable
                where workflowTrackingStatusTable.CorrelationId==workflowworkitemTable.CorrelationId
                && workflowworkitemTable.Status==WorkflowWorkItemStatus::Pending
            //&& workflowworkitemTable.UserId == 'prasan.k'
            && workflowworkitemTable.modifiedDateTime >= dateStart
        //TODO:Uncomment the date criteia when release to LIVE
            outer Join  workflowtrackingtable
                where workflowtrackingtable.Workflowtrackingstatustable==workflowTrackingStatusTable.recId
                && workflowtrackingtable.TrackingType == WorkflowTrackingType::Submission
                && workflowtrackingtable.User == workflowworkitemTable.UserId
            outer join  workflowtrackingcommenttable
                where workflowtrackingcommenttable.trackingid ==workflowtrackingtable.trackingId
        {

}

No comments:

Post a Comment