Dynamics 365 - Jscript/fetchXML 问题:链接实体以过滤字段

问题描述 投票:0回答:1

我要创建的过滤器如下:我要过滤位于我的表 (msdyn_customerasset) 中的字段 (uneeti_agreementinvoiceproduct)。过滤器必须满足以下条件:首先,合约的客户必须等于资产账户。在我的表 (msdyn_agreementinvoiceproduct) 的 fetchXML 查询中,我将检索链接的合同表 (msdyn_agreement) 和字段 (msdyn_serviceaccount) 进行比较。其次,我想仅显示已与合约资产关联的产品。因此,我从表 (msdyn_customerasset) 中检索产品字段,并从表 (msdyn_agreementinvoiceproduct) 中获取 (msdyn_product)。这是我的检索查询以及发生的错误。我不明白这个错误,因为指定的字段与指示的表没有关联。

ERROR

function filterProductContratFS(context) {

var formContext = context.getFormContext();

var fieldRecipientCall = formContext.getAttribute("msdyn_account").getValue();
var fieldRecipientCall2 = formContext.getAttribute("msdyn_product").getValue();

if (fieldRecipientCall && fieldRecipientCall2) {
    var accountId = fieldRecipientCall[0].id;
    var productId = fieldRecipientCall2[0].id;

    console.log(accountId);
    console.log(productId);

    var fetchXML =
        "<fetch>" +
        "<entity name='msdyn_agreementinvoiceproduct'>" +
        "<link-entity name='msdyn_agreement' from='msdyn_agreementid' to='msdyn_agreement'>" +
        "<filter>" +
        "<condition attribute='msdyn_serviceaccount' operator='eq' value='" + accountId + "' uitype='account'/>" +
        "</filter>" +
        "</link-entity>" +
        "<link-entity name='msdyn_customerasset' from='msdyn_customerassetid' to='msdyn_agreementinvoiceproductid'>" +
        "<filter>" +
        "<condition attribute='msdyn_product' operator='eq' value='" + productId + "' />" +
        "</filter>" +
        "</link-entity>" +
        "</entity>" +
        "</fetch>";

    var agreementInvoiceProductControl = formContext.getControl("uneeti_agreementinvoiceproduct");
    agreementInvoiceProductControl.addPreSearch(function () {
        agreementInvoiceProductControl.addCustomFilter(fetchXML);
    });

} else {
    return;
}}

有人可以帮我解决这个问题吗?

javascript function fetch dynamics-crm
1个回答
0
投票

您应该仔细检查 addCustomFilter 函数的工作原理。它只接受过滤器本身。所以没有实体,没有链接实体等等。我知道你可能使它起作用的唯一方法在这里描述 - https://missdynamicscrm.blogspot.com/2014/08/crm-2013-using-addcustomfilter-to-get-filtered-lookup-field-based-on -linked-entity.html

© www.soinside.com 2019 - 2024. All rights reserved.