MSCRM CRM 获取PickList 字段值函数解决方案

表单中有很多picklist字段 不想写链接stringmap
代码:

实体ID查询方法:
 SELECT ObjectTypeCode from Entity  where  name='实体名称'

调用函数方法:
select  dbo.getpicklist('字段名称',字段值,实体ID)

--@AttributeName 字段名称
--@AttributeValue 字段值
--@EntityName 实体名称
create function GetPickList(
@AttributeName varchar(100),
@AttributeValue int,
@EntityName varchar(100)
)
returns varchar(100)
as
begin
declare @value varchar(100)
SELECT @value=Value FROM StringMap where AttributeName=@AttributeName AND AttributeValue=@AttributeValue and ObjectTypeCode=(SELECT ObjectTypeCode from Entity where name= @EntityName)
return @value
end

原文地址:https://www.cnblogs.com/guozh-bk/p/5344417.html