简体   繁体   English

获取Dynamics CRM元数据

[英]Getting Dynamics CRM Metadata

I'm using Microsoft Dynamics CRM 2016 On Premise, I'm trying to get some specific metadata, basically get through SQL Server the field physical name, display name(Label) and the field value from a given entity. 我正在使用Microsoft Dynamics CRM 2016 Premise,我试图获取一些特定的元数据,基本上是通过SQL Server获取给定实体的字段物理名称,显示名称(标签)和字段值。 This is the query I have so far: 这是我到目前为止的查询:

 select  a.PhysicalName, I.Label
 from  [dbo].[Attribute] a
 inner join [dbo].[Entity] e on e.EntityId=a.EntityId
 inner join [dbo].[LocalizedLabel] l on l.ObjectId = a.AttributeId
 where e.Name='DesiredEntityName'

With this query I can get the fields and displayed label from the given entity, however I don't see the way on how to join and get the list of values for each field. 通过此查询,我可以从给定实体中获取字段和显示的标签,但是我看不到如何联接和获取每个字段的值列表的方法。

You have to query from stringmap table where all the picklist (optionset) values will be stored. 您必须从stringmap所有选择列表(选项集)值的stringmap表中查询。

SELECT AttributeValue as Value, Value as Label
FROM StringMap s
JOIN EntityLogicalView e on s.ObjectTypeCode = e.ObjectTypeCode
WHERE AttributeName = 'DesiredAttributeName'
AND e.Name = 'DesiredEntityName'
ORDER BY DisplayOrder

Retrieve Option Set Metadata Via SQL 通过SQL检索选项集元数据

Edit: 编辑:

I see what you want now. 我现在知道你想要什么。 You basically need to mimic what Product is doing when you export the data to Excel. 当您将数据导出到Excel时,您基本上需要模仿Product在做什么。

When you do the below query using database table or view or filtered view, you want the display name as ALIAS. 使用数据库表或视图或过滤视图执行以下查询时,您希望显示名称为ALIAS。

SELECT name AS [Account Name], telephone1 AS [Business Phone]  from Account

The problem would be that Schema Name telephone1 is readily available in table where Account records data is stored, whereas Display Name Business Phone is stored in multiple different tables like Entity, Attribute, LocalizedLabel . 这个问题将是架构名称 telephone1是在帐户记录数据存储表一应俱全,而显示名称 Business Phone存储在像实体,属性,LocalizedLabel多个不同的表。

You may have to do your own view or query concatenation to achieve this. 您可能必须做自己的视图或查询串联才能实现此目的。

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

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