Recently, I have come across an issue where, I need to fetch the last approver ‘s name who approved the workflow document and the approved date.

Note: It can be applied to any workflow document which has workflow enabled like(Journal, Puchase Order, Purch Requistion etc,)

Below is th code

static void Job19(Args _args)

WorkflowTrackingStatusTable workflowTrackingStatus;
WorkflowTrackingTable workflowTrackingTable;
WorkflowTrackingCommentTable workflowTrackingCommentTable;
UserInfo userInfo;

select firstFast RecId, User from workflowTrackingTable
order by RecId desc
join workflowTrackingCommentTable
where workflowTrackingCommentTable.WorkflowTrackingTable == workflowTrackingTable.RecId
join UserInfo
where == WorkflowTrackingTable.User
exists join workflowTrackingStatus
where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatus.RecId
&& workflowTrackingStatus.ContextRecId == _purchRecId //PurchRecID
&& workflowTrackingStatus.ContextTableId == tableNum(PurchTable) //PurchTable
&& workflowTrackingTable.TrackingType == WorkflowTrackingType::Approval;
if (workflowTrackingTable.RecId > 0)

info(strFmt(“%1 – %2 “,, workflowTrackingCommentTable.RecId));