最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

D365: 如何在 X++ 中获取最后一个工作流程审批人/D365: How to get last workflow approver in X++

网络文摘 William 178浏览 0评论

Purpose:

Demonstrates how can get the last workflow approver for purchase orders in X++.

Application:

Dynamics 365 for Finance and Operations

Business requirement:

Get the last workflow approver for purchase orders in X++.

Solution:

We can use the code below to get the last workflow approver for purchase orders. The code extends PurchTable table to add a method to get the last workflow approver.

Code

[ExtensionOf(tableStr(PurchTable))]
internal final class MK_PurchTable_Extension
{
    /// <summary>
    /// Gets the last workflow approver.
    /// </summary>
    /// <remarks>Muhammad Anas Khan</remarks>
    public UserId getLastWorkflowApprover()
    {
        WorkflowTrackingStatusTable workflowTrackingStatusTable;
        WorkflowTrackingTable workflowTrackingTable;
        UserInfo userInfo;
        UserId ret;

        select firstonly workflowTrackingTable
            join workflowTrackingStatusTable
                where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
                    && workflowTrackingStatusTable.ContextTableId == this.TableId
                    && workflowTrackingStatusTable.ContextRecId == this.RecId
                    && workflowTrackingTable.TrackingType == WorkflowTrackingType::Approval
            join userInfo
                where workflowTrackingTable.User == userInfo.id;

        if (workflowTrackingTable.RecId)
        {
            ret = userInfo.id;
        }

        return ret;
    }
}
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址