简体   繁体   English

Dynamics crm 在通过 api 获取时删除重复数据

[英]Dynamics crm remove the repeated data while fetching via api

Trying to retrieve all state under one particular country.试图检索某个特定国家/地区下的所有 state。

URL: URL:

api/data/v9.1/leadaddresses?$select=stateorprovince&$filter=stateorprovince ne  null and country eq 'US'&$count=true&$orderby=stateorprovince

Problem here is it returns data like this这里的问题是它返回这样的数据

"value": [
  {
"@odata.etag": "W/"166729382"",
"stateorprovince": "AK",
"leadaddressid": "691de670-aa45-426b-8fee-00b3a7f7e469"
},
  {
"@odata.etag": "W/"166729369"",
"stateorprovince": "AK",
"leadaddressid": "12db5897-dc53-44ae-b4aa-03c5486ad6ac"
},
  {
"@odata.etag": "W/"166729416"",
"stateorprovince": "AK",
"leadaddressid": "f64ccf06-fa67-421a-aa5f-0469302be1c2"
},
  {
"@odata.etag": "W/"166729206"",
"stateorprovince": "AK",
"leadaddressid": "b1f9ce4a-a06b-4d7d-befc-04bea0d41a4e"
},
  {
"@odata.etag": "W/"166729323"",
"stateorprovince": "AK",
"leadaddressid": "a4b9ff56-2d24-4957-b09b-04ef6ce56304"
},

Any way to remove the repeated data.任何删除重复数据的方法。

You have to use fetchxml to get distinct values, that is the only option.您必须使用 fetchxml 来获取不同的值,这是唯一的选择。

<fetch top="50" distinct="true" >
  <entity name="leadaddress" >
    <attribute name="stateorprovince" />
    <filter type="and" >
      <condition attribute="stateorprovince" operator="not-null" />
    </filter>
  </entity>
</fetch>

You can use web api endpoint and use the above fetchxml like below:您可以使用 web api 端点并使用上面的 fetchxml,如下所示:

https://crmdev.crm.dynamics.com/api/data/v9.1/leadaddresses?fetchXml=<fetch top="50" distinct="true" >   <entity name="leadaddress" >     <attribute name="stateorprovince" />     <filter type="and" >       <condition attribute="stateorprovince" operator="not-null" />     </filter>   </entity> </fetch>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM