Источник:
https://dynamicsaxinsight.wordpress....e-orders-in-x/
==============
Purpose:
In this post we’re going to see how can we get last workflow approver for purchase orders in X++.
Application:
Dynamics 365 for Finance and Operations.
Business requirement:
Get the last purchase order approver in X++.
Solution:
Please use the code below to get the last purchase order approver.
Tip:
Take a note that workflow tables are cross-company tables. That’s why it is important to change company when making joins with them, else you will get empty table buffers!
Code
/// /// Gets workflow last approver for purchase orders./// public void getPurchWorkflowApprovers(){ WorkflowTrackingStatusTable workflowTrackingStatusTable; WorkflowTrackingTable workflowTrackingTable; PurchTable purchTable; PurchTable purchTableWTT; while select crosscompany purchTable { changecompany(purchTable.DataAreaId) { select firstonly crosscompany workflowTrackingTable order by workflowTrackingTable.RecId desc join workflowTrackingStatusTable where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId join purchTableWTT where workflowTrackingStatusTable.ContextTableId == tableNum(PurchTable) && workflowTrackingStatusTable.ContextCompanyId == purchTableWTT.DataAreaId && workflowTrackingStatusTable.ContextRecId == purchTableWTT.RecId && workflowTrackingTable.TrackingContext == workflowtrackingcontext::WorkItem && workflowTrackingTable.TrackingType == workflowtrackingtype::Approval && purchTableWTT.RecId == purchTable.RecId; info(strFmt("%1, %2", purchTable.PurchId, workflowTrackingTable.User)); } }}
Источник:
https://dynamicsaxinsight.wordpress....e-orders-in-x/