x ++从recid获取resourcename

时间:2017-04-28 13:41:57

标签: reporting-services axapta x++ dynamics-365-operations

我已经大量定制了项目交易报告(projlisttransproj,我正在显示资源ID。我想显示该资源的名称(参见插入方法)。我公平地说非常感谢x ++开发的新功能。我已经看过projtrans类并在下面找到了,但没有发现任何名称...谢谢!

/// <summary>
    /// Retrieves the ID of the employee that is associated with this transaction depending on the
    /// transaction type that is returned by the <c>ProjTrans.transType</c> method.
    /// </summary>
    /// <returns>
    /// The <c>RecID</c> value of the employee that is associated with this transaction.
    /// </returns>
    /// <remarks>
    /// For hour, cost, and revenue transactions, the employee ID will be returned. For all other
    /// transactions, 0 will be returned.
    /// </remarks>
    public ResourceRecId projIdentResource()
    {
        ResourceRecId     resourceRecId;

        switch(this.transType())
        {
            case ProjTransType::Hour:
            case ProjTransType::Cost:
            case ProjTransType::Revenue:
                resourceRecId   = this.resource();
                break;
            default:
                resourceRecId   = 0;
        }

        return resourceRecId;
    }

enter image description here

public void insertProjTransList()
    {
        tmpProjTransListExtension.clear();
        tmpProjTransListExtension.VoucherInvoice    = projTrans.voucherInvoice();
        tmpProjTransListExtension.VoucherJournal    = projTrans.voucherOriginal();
        tmpProjTransListExtension.LinePropertyId    = projTrans.linePropertyId();
        tmpProjTransListExtension.ActivityNumber    = projTrans.activityNumber();
        tmpProjTransListExtension.CategoryId        = projTrans.categoryId();
        tmpProjTransListExtension.CostPrice         = projTrans.costPrice();
        tmpProjTransListExtension.CurrencyId        = projTrans.currencyIdSales();
        tmpProjTransListExtension.DefaultDimension  = projTrans.defaultDimension();
        tmpProjTransListExtension.SalesAmount       = projTrans.transTurnoverMST();
        tmpProjTransListExtension.CostAmount        = projTrans.transCostMST();
        tmpProjTransListExtension.ProjIdOrig        = projTrans.projId();
        tmpProjTransListExtension.ProjId            = firstProjId;
        tmpProjTransListExtension.Qty               = projTrans.qty();
        tmpProjTransListExtension.SalesPrice        = projTrans.salesPrice();
        tmpProjTransListExtension.TransDate         = projTrans.transDate();
        tmpProjTransListExtension.Txt               = projTrans.txt();
        tmpProjTransListExtension.TransType         = projTrans.transType();
        tmpProjTransListExtension.ProjId            = firstProjId;
        TmpProjTransListExtension.ProjName          = firstProjName;
        tmpProjTransListExtension.Type              = ProjCategory::find(projTrans.categoryId()).CategoryType;
        TmpProjTransListExtension.Resource          = ProjTrans.resource(); //Want Name of resource not ID
        tmpProjTransListExtension.insert();
    }

1 个答案:

答案 0 :(得分:1)

您可以使用HcmWorker::find(ProjTrans.resource()).name()获取工作人员的姓名。