sql – 如何加入dbo.LocalizedLabelView以获取Dynamics CRM中的表单标签?

在Dynamics CRM中,我经常从业务用户那里获得创建报告的要求.业务用户了解并谈论实体显示名称属性标签.要编写查询,我需要将它们映射到实体名称属性名称.我想用一个查询来查看.

我将如何加入dbo.LocalizedLabelView视图以获取以下查询中的AttributeLabel列?我无法弄清楚ObjectId应该引用什么. (如果你能告诉我你是如何找到答案我会特别感激的!)

select
    [EntityName]           = entityNames.Name,[EntitydisplayName]    = entitydisplayNames.Label,[AttributeName]        = attributeNames.PhysicalName,[AttributedisplayName] = attributedisplayNames.Label
    --[AttributeLabel]     = attributeLabels.Label
from 
    dbo.EntityView entityNames

    inner join dbo.LocalizedLabelView entitydisplayNames
        on entitydisplayNames.ObjectId = entityNames.EntityId
        and entitydisplayNames.ObjectColumnName = 'Localizedname'

    left outer join dbo.AttributeView attributeNames
        on attributeNames.EntityID = entityNames.EntityID

    inner join dbo.LocalizedLabelView attributedisplayNames
        on attributedisplayNames.ObjectId = attributeNames.AttributeID
        and attributedisplayNames.ObjectColumnName = 'displayName'
        and attributedisplayNames.LanguageID = entitydisplayNames.LanguageID

    --inner join dbo.LocalizedLabelView attributeLabels
    --  on attributeLabels.ObjectId = ?????
    --  and attributeLabels.LanguageID = entitydisplayNames.LanguageID
where
    entitydisplayNames.LanguageID = 1033
order by
    entitydisplayNames.Label,attributedisplayNames.Label

解决方法

ObjectId是对CRM数据库中事物的内部ID的引用.这个东西可以是属性,实体,标签等等.

由于您需要属性标签,因此请在此处使用该属性的id作为ObjectId.我想你希望你的连接条件看起来像这样:

inner join dbo.LocalizedLabelView attributeLabels
    on attributeLabels.ObjectId = attributeNames.AttributeID
    and attributeLabels.LanguageID = entitydisplayNames.LanguageID
    and attributeLabels.ObjectColumnName = 'displayName'

如果需要属性的描述,可以将ObjectColumnName更改为“Description”.

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...