Monday, May 13, 2019

How to get workflow submitted userID and Datetime in D365 Finance & Operations x++

In this post I'll be sharing a job to get purchase order workflow submitted userID and datetime.

Change the logic according to your requirement.


class WorkflowUserDatetime
{     
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {
        WorkflowTrackingTable workflowTrackingTable;
        WorkflowTrackingStatusTable workflowTrackingStatusTable;
        WorkflowTrackingCommentTable    workflowTrackingCommentTable;
        PurchTable  purchTable = PurchTable::find('POV002357'); // Change the table name


        select firstFast RecId, User,CreatedDateTime from workflowTrackingTable
            order by RecId desc
            join workflowTrackingCommentTable
            where workflowTrackingCommentTable.WorkflowTrackingTable == workflowTrackingTable.RecId
            exists join workflowTrackingStatusTable
            where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
            && workflowTrackingStatusTable.ContextRecId == purchTable.RecId // Change table recid
            && workflowTrackingStatusTable.ContextTableId == purchTable.TableId // Change table ID
            && workflowTrackingTable.TrackingType == WorkflowTrackingType::Submission;// Change the enum value to approval to get approved user details

        if (workflowTrackingTable.RecId > 0)
        {
            Info(strFmt("%1 - %2", workflowTrackingTable.CreatedDateTime , workflowTrackingTable. User));
        }
    }

}

@Rahul

1 comment:

Why do users often get confused about Dynamics 365 Customer Engagement (D365 CE), Dataverse, and the Power Platform?

  The Microsoft ecosystem for business applications can sometimes be difficult to navigate, especially when discussing Dynamics 365 Customer...