8
在Dynamics CRM中,我經常從業務用戶那裏獲得創建報表的要求。商業用戶知道並談論實體顯示名稱和屬性標籤。要編寫查詢,我需要將這些映射到實體名稱和屬性名稱。我想用查詢來查看這個。如何加入dbo.LocalizedLabelView以獲取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