zoukankan      html  css  js  c++  java
  • 使用Dynamics 365 CE Web API查询数据加点料及选项集字段常用查询

    微软动态CRM专家罗勇 ,回复336或者20190516可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me.

    紧接上文:配置Postman通过OAuth 2 implicit grant获取Dynamics 365 CE Online实例的Access Token 。

    我这用来执行一个查询语句如下:

    {{webapiurl}}contacts?$select=gendercode,isbackofficecustomer,_ownerid_value,birthdate,createdon,_createdby_value,cr095_decimal,cr095_revenue&$filter=cr095_decimal ne null 

    返回结果如下,可以看到返回的数据没有格式化:

    如果我给查询加点料呢,就是HTTP Request Header加点东西:Prefer: odata.include-annotations="OData.Community.Display.V1.FormattedValue"

    就会发现字段的显示值出来了,而且是根据当前调用者身份的个人设置的格式进行了格式化。

    再下猛一点,加上:Prefer: odata.include-annotations="*"  

    结果如下。

    增加返回了如下四个属性:

    @Microsoft.Dynamics.CRM.totalrecordcount

    @Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded

    @Microsoft.Dynamics.CRM.morerecords

    @Microsoft.Dynamics.CRM.fetchxmlpagingcookie

    并且对于查找字段还增加返回了:Microsoft.Dynamics.CRM.associatednavigationproperty 和 Microsoft.Dynamics.CRM.lookuplogicalname 两个annotation。

    对于选项集字段,如何看这个选项集有哪些选项呢?

    假设我想看逻辑名称为 contact 实体的逻辑名称为 gendercode 字段的在英语环境下的可用选项的话,用如下的查询语句:

    {{webapiurl}}stringmaps?$select=value,attributevalue&$filter=objecttypecode eq 'contact' and attributename eq 'gendercode' and langid eq 1033

    如果前面的查询没有查出来选项集的显示文本,只返回了选项集字段的值,那么可以用类似下面的语句查询其在某种语言下的显示值:

    {{webapiurl}}stringmaps?$select=value&$filter=objecttypecode eq 'contact' and attributename eq 'gendercode' and langid eq 1033 and attributevalue eq 1

  • 相关阅读:
    团队项目-选题报告
    第一次结对编程作业
    第一次个人编程作业
    第一次软工作业
    antd form表单数组对象格式
    antd form表单验证失去焦点时验证和重置验证状态
    fetch请求
    typescript类装饰器
    typescript泛型
    浮点数问题
  • 原文地址:https://www.cnblogs.com/luoyong0201/p/Dynamics_365_Web_API_Query_More_Optionset_Display_Value.html
Copyright © 2011-2022 走看看