Monday 13 May 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:

Adding a newline into a string in C# and X++

Below is the sample code we can use for  adding a newline after every occurrence of "@" symbol in the string in C#   using System...