Sunday 22 September 2024

AX365 X++ Get the current Workflow Step name

 Here is a method to get the current workflow step name using X++ just pass the table rec id which is applied to the workflow and you can get the step name


public static str getCurrentStepName(RecId _Id)

{

    WorkflowTrackingTable _WorkflowTrackingTable;

    WorkflowTrackingStatusTable _WorkflowTrackingStatusTable;

    WorkflowElementTable _WorkflowElementTable;

    


    select firstonly _WorkflowTrackingTable

        order CreatedDateTime desc

       join _WorkflowTrackingStatusTable

        where _WorkflowTrackingStatusTable.RecId == _WorkflowTrackingTable.WorkflowTrackingStatusTable

        join _WorkflowElementTable

        where _WorkflowElementTable.RecId == _WorkflowTrackingTable.WorkflowElementTable

       && _WorkflowTrackingTable.TrackingType == WorkflowTrackingType::Creation

       && _WorkflowTrackingTable.TrackingContext == WorkflowTrackingContext::Step

        && _WorkflowTrackingStatusTable.ContextRecId == _Id

        && _WorkflowTrackingStatusTable.ContextTableId == tableNum(InventTable)

       ;

                

   

    return _WorkflowElementTable.ElementName;

}

No comments:

Post a Comment