Optionsetlerin adlarını getiren dinamik SQL Function
Optionsetlerin adlarını getiren dinamik SQL Function ın create ifadesi aşağıdaki gibidir.
4 Parametre alıyor;
@EntityName : Entity Adı
@LangId : Dil Kodu. Bildiğiniz gibi Türkçe 1055, İngilizce 1033
@AttributeName : Optionset adı
@AttributeValue : Optionset değeri
Örnek kullanım şekli;
Select dbo.fn_GetStringMapValue(‘contact’,1055,’new_kartiptalnedenleri’,new_kartiptalnedenleri) from contactbase where mobilephone=’53xxxxxxx’
/****** Object: UserDefinedFunction [dbo].[fn_GetStringMapValue] Script Date: 20.10.2026 11:15:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[fn_GetStringMapValue]
(
@EntityName nvarchar(100),
@LangId INT,
@AttributeName NVARCHAR(100),
@AttributeValue INT
)
RETURNS NVARCHAR(2000)
AS
BEGIN
DECLARE @Deger NVARCHAR(500);
DECLARE @ObjectTypeCode int;
select @ObjectTypeCode = ObjectTypeCode from crm_MSCRM..EntityView where name=@EntityName;
SELECT @Deger = MAX(Value)
FROM crm_MSCRM..StringMapBase WITH (NOLOCK)
WHERE ObjectTypeCode = @ObjectTypeCode
AND LangId = @LangId
AND AttributeName = @AttributeName
AND AttributeValue = @AttributeValue;
RETURN @Deger;
END
GO
Share this content:
Yorum gönder