Dynamics CRM 2016:不要使用 XRM 服务工具包检索帐户 ID

Dynamics CRM 2016: Do not retrieving account id using XRM Service Tool kit

在下面的代码片段中,如果父帐户 ID 匹配,我将尝试获取子帐户。它按预期填充帐户名称,例如 ABC Title CompanyTest Tile Co.,但它填充帐户 ID 为 undefined

XRM Service Toolkit 在 CRM 2016 检索子帐户的详细信息。我不知道帐户 ID 出了什么问题我仔细检查了属性的拼写,但没有得到任何支持。

functiongetChildAccounts(pAccountId)
{
var query =
            "<a:ColumnSet>" +
            "<a:AllColumns>false</a:AllColumns>" +
            "<a:Columns xmlns:b='http://schemas.microsoft.com/2003/10/Serialization/Arrays'>" +
            "<b:string>name</b:string>" +
            "<b:string>accountid</b:string>" +
          "</a:Columns>" +
        "</a:ColumnSet>" +
        "<a:Criteria>" +
          "<a:Conditions />" +
          "<a:FilterOperator>And</a:FilterOperator>" +
          "<a:Filters>" +
"<a:FilterExpression>" +
  "<a:Conditions>" +
    "<a:ConditionExpression>" +
      "<a:AttributeName>parentaccountid</a:AttributeName>" +
      "<a:Operator>Equal</a:Operator>" +
      "<a:Values xmlns:b='http://schemas.microsoft.com/2003/10/Serialization/Arrays'>" +
        "<b:anyType i:type='c:string' xmlns:c='http://www.w3.org/2001/XMLSchema'>"+ pAccountId +"</b:anyType>" +
      "</a:Values>" +
    "</a:ConditionExpression>" +
  "</a:Conditions>" +
  "<a:FilterOperator>And</a:FilterOperator>" +
  "<a:Filters />" +
"</a:FilterExpression>" +
          "</a:Filters>" +
        "</a:Criteria>" +
        "<a:Distinct>false</a:Distinct>" +
        "<a:EntityName>account</a:EntityName>" +
        "<a:LinkEntities />" +
        "<a:Orders />" +
        "<a:PageInfo>" +
          "<a:Count>0</a:Count>" +
          "<a:PageNumber>0</a:PageNumber>" +
          "<a:PagingCookie i:nil='true' />" +
          "<a:ReturnTotalRecordCount>false</a:ReturnTotalRecordCount>" +
        "</a:PageInfo>" +
        "<a:NoLock>false</a:NoLock>";

        var childAccounts = XrmServiceToolkit.Soap.RetrieveMultiple(query);

        alert(childAccounts[0].attributes['name'].value);
        alert(childAccounts[0].attributes['accountid'].id);
}

对于您的代码,您可以使用类似这样的东西,因为它将为您提供帐户 ID。

警报(childAccounts[0].id);

您可以使用调试和监视来获取值的表达式。