在以下代码片段中,如果父帐户 ID 匹配,我将尝试获取子帐户。它正在按预期填充帐户名称,例如ABC Title Company
orTest Tile Co.
但将帐户 ID 填充为undefined
.
我在 CRM 2016 上检索子帐户详细信息的XRM 服务工具包。我不知道帐户 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);
}