更改视图以将属性值作为新属性

时间:2018-07-20 04:35:38

标签: sql sql-server-2008 dynamics-crm dynamics-crm-2011

我需要添加一个属性值作为新属性。

enter image description here

我想在我的视图中将“值”列添加为新属性。如何在SQL Server 2008中做到这一点?我们正在使用Dynamics 2011,并且可以在我们的合作伙伴门户网站上使用。我对SQL不好,所以为什么要问。

用于获取Attribtues和AttributeValue表的SQL查询是:

<jqxDropDownList #myDropDownList [theme]='”summer”‘
[width]=”200″ [height]=”50″ (onSelect)=”Select($event)” [source]=”source” [selectedIndex]=”0″ [autoOpen]=”true”>
</jqxDropDownList>

3 个答案:

答案 0 :(得分:0)

Dynamics CRM已经附带了开箱即用的视图,该视图显示了选项集的可读性。这些视图称为Filtered Views,也符合CRM中的安全模型。

我建议您仅将过滤后的视图用于您的实体。如果您确实需要创建自己的视图,则始终可以从如何创建默认视图中找到灵感。

答案 1 :(得分:0)

如果使用普通表查询,则将直接从您的实体获取整数值(代码),并且必须与StringMapBase表进行内部联接以获取标签(名称)。 Read more

select AttributeName, AttributeValue, Value from StringMapBase
where LangId = 1033 and AttributeName = 'TheNameOfTheAttribute'

像Henrik所说,FilteredViews是您最好的选择。由于某种原因,如果您有自己的视图,请在视图定义中像上述查询一样拉出AttributeValue

  

所有下拉列表(选项集)对于列表中的每个字符串都有两个关联的字段。对于每个字符串,都有一个值(代码)字段和一个标签(名称)字段,例如Leadsource和Leadsourcename。例如,线索的过滤视图返回两个与类型Picklist的LeadSource属性相关的字段:LeadSource = 1和LeadSourceName =“ Advertisement”。报告显示标签字段,并将值字段用于数字比较。

参考:Use SQL and filtered views to retrieve data for reports

答案 2 :(得分:0)

解决方案是在sql server中使用函数,该函数将返回我需要的值:

CREATE function [dbo].[getAttributeValue]
(
    @attributename nvarchar(100), @attributevalue int 
)
RETURNS nvarchar(4000)
AS
BEGIN
-- Declare the return variable here
DECLARE @value nvarchar(4000)

select @value = value
from pt_mirror_stringmap
where attributename = @attributename
    and attributevalue = @attributevalue

-- Return the result of the function
RETURN @value
END