Small tip, with reference at the end of post. I got small task, User want Last approval Name in grid at the result.
I wrote following code snippet as method in a required table and bind it to grid field.
display Name LastApprovalName() { WorkflowTrackingStatusTable workflowTrackingStatus; WorkflowTrackingTable workflowTrackingTable; WorkflowTrackingCommentTable workflowTrackingCommentTable; UserInfo userInfo; RecId _recId; Name _name; _recId=5637145391; select firstFast RecId, User from workflowTrackingTable order by RecId desc join workflowTrackingCommentTable where workflowTrackingCommentTable.WorkflowTrackingTable == workflowTrackingTable.RecId join UserInfo where UserInfo.id == WorkflowTrackingTable.User exists join workflowTrackingStatus where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatus.RecId && workflowTrackingStatus.ContextRecId == this.RecId && workflowTrackingStatus.ContextTableId == tableNum(MyTablelRequestTable) //PurchTable && workflowTrackingTable.TrackingType == WorkflowTrackingType::Approval; if (workflowTrackingTable.RecId > 0) { _name=userInfo.name; } else { _name=''; } return _name; }
Original Code snippet is https://community.dynamics.com/ax/b/amazingax1/archive/2016/04/28/microsoft-dynamics-ax-2012-get-workflow-last-approver-name-and-approved-date