【问题标题】:Dynamic 365 - Retrieve API Metadata Attribute List - DateTimeBehaviorDynamic 365 - 检索 API 元数据属性列表 - DateTimeBehavior
【发布时间】:2021-07-15 08:52:46
【问题描述】:

我们已经开始使用动态 API 来检索实体的属性列表以用于迁移,如下所示:

GET [Organization URI]/api/data/v9.0/EntityDefinitions(LogicalName='contact')?$select=LogicalName,AttributeOf,AttributeType HTTP/1.1  
Accept: application/json  
OData-MaxVersion: 4.0  
OData-Version: 4.0  

对于“DateTime”属性类型字段,在其调用 DateTimeBehavior 中有一个属性具有“DateOnly”值:

"DateTimeBehavior": {
  "Value": "DateOnly"
}

我们需要知道这一点才能将旧数据转换为 DateTime 或 Date 字段。但是,如果我们在 GET api 调用的 $select 中包含 DateTimeBehavior,我们将得到:

{
  "error": {
    "code": "0x0",
    "message": "Could not find a property named 'DateTime' on type 'Microsoft.Dynamics.CRM.AttributeMetadata'."
  }
}

因此,我们不得不对每个“DateTime”属性类型字段进行单独调用,以发现它是否为“DateOnly”。

有没有一种方法可以 $select 实体中的所有属性,如果存在此“DateOnly”字段?

非常感谢任何帮助。

【问题讨论】:

    标签: dynamics-crm microsoft-dynamics dynamics-crm-online dynamics-crm-365 dynamics-crm-webapi


    【解决方案1】:

    我不相信。 In order to retrieve the properties of a specific type of attribute you must cast the Attributes collection-valued navigation property to the type you want.

    但是,您可以一次取回所有日期时间属性及其相应的 DateTimeBehavior 实体/表(而不是一次查询每个属性)。

    GET /api/data/v9.0/EntityDefinitions(LogicalName='account')/Attributes/Microsoft.Dynamics.CRM.DateTimeAttributeMetadata?$select=LogicalName,DateTimeBehavior
    

    【讨论】:

    • 谢谢马特,这是我的解决方法,很高兴确认没有其他方法
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-05
    • 1970-01-01
    • 2021-06-21
    • 1970-01-01
    • 2018-08-17
    • 2013-07-21
    • 2015-01-29
    相关资源
    最近更新 更多