1

是否可以使用$expand但不返回对象集合,只返回对象的数量?

例如,在单个 WebApi 调用中获取帐户及其注释计数

我已经尝试了几件事。

  • 明显的尝试:accounts(6CDEEB72-2AC8-E711-A825-000D3AE0A7F8)?$select=name&$expand=Account_Annotation($count=true)返回所有注释的所有字段,但不计算任何内容。

  • 接下来我尝试accounts(6CDEEB72-2AC8-E711-A825-000D3AE0A7F8)?$select=name&$expand=Account_Annotation($select=annotationid&$count=true) 返回错误:“找到不平衡的括号表达式”。我认为这&$expand

  • 我发现一个非 crm 博客说这可以用 a 解决,;但是当我尝试accounts(6CDEEB72-2AC8-E711-A825-000D3AE0A7F8)?$select=name&$expand=Account_Annotation($select=annotationid;$count=true)时它没有给出错误,但$count指令似乎被忽略了

  • accounts(6CDEEB72-2AC8-E711-A825-000D3AE0A7F8)?$select=name&$count=Account_Annotation($select=annotationid)返回“无效计数”错误的疯狂尝试

我猜这不是一个有效的组合,但我想我会在这里发帖,以防其他人成功实现这一目标。

4

1 回答 1

0

我得到了这个工作,但我不确定它是否是你正在寻找的东西,它只有在我将计数放在展开之前才有效:

api/data/v9.0/cmnt_salesexample?
$select=endcustomeraccountid&$count=true&$expand=endcustomerid($select=accountid)

输出:

{
"@odata.context": "https://xyz",
"@odata.count": 5000,
"value": [
 {
  "@odata.etag": "W/\"3560581422\"",
  "endcustomerid": "54321"
},
{
  "@odata.etag": "W/\"3510396844\"",
  "endcustomerid": "12345"  
},
...
于 2019-02-14T14:41:54.557 回答