在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”.