2016-11-01 8 views
0

アカウントとリレーションシップタイプ(カスタムエンティティ)の間にN:Nの関係があります。レコードエンティティ(別のカスタムエンティティ)で、私はアカウントの検索をしています。検索条件にリレーションシップタイプの 'Vendor'リレーションを持つ特定のものだけを表示できるように、presearch条件を追加します。これまでは、スニペットを実行して検索を行うようにしましたが、すべてのレコードが表示されます。私はどこが間違っているのか分かりません。任意のアイデア/提案?Dynamics CRMのアカウント検索で特定の勘定科目レコードを表示

function filterAccounts() { 
    try { 
     debugger; 
     var accountLookup = Xrm.Page.getControl("new_accountid"); 
     if (accountLookup == null && accountLookup == 'undefined') { } 
     else { 
      accountLookup.addPreSearch(function() { 

       CustomFilter(accountLookup); 
      }); 
     } 

    } catch (e) { 
     alert("Error: " + e.message); 
    } 

} 

function CustomFilter(accountLookup) { 
    try { 
     debugger; 
     var fetchXml = "<link-entity name='new_account_new_relationshiptype' from='accountid' to='accountid' visible='false' intersect='true'>" + 
         "  <link-entity name='new_relationshiptype' from='new_relationshiptypeid' to='new_relationshiptypeid' alias='ak'>" + 
         "  <filter type='and'>" + 
         "   <condition attribute='new_name' operator='eq' value='Vendor' />" + 
         "  </filter>" + 
         "  </link-entity>" + 
         " </link-entity>"; 

      accountLookup.addCustomFilter(fetchXml); 
    } catch (e) { 
     alert("Error: " + e.message); 

    } 
} 

答えて

1

あなたはaddCustomFilterで指定FetchXMLは<filter> -partであることを意味します。 addCustomFilterを使用する場合、リンクエンティティを指定することはできません。

アカウントエンティティのフィールドだけを考慮する必要がないようにクエリを単純化できない場合は、addCustomFilterの代わりにaddCustomViewを使用する必要があります。

関連する問題