UFN_MKTSOURCECODE_GETDEFAULTSOURCECODEID2

Returns the ID of the default source code available to the current user.

Return

Return Type
uniqueidentifier

Parameters

Parameter Parameter Type Mode Description
@CURRENTAPPUSERID uniqueidentifier IN
@SECURITYFEATUREID uniqueidentifier IN
@SECURITYFEATURETYPE tinyint IN

Definition

Copy


CREATE function dbo.[UFN_MKTSOURCECODE_GETDEFAULTSOURCECODEID2]
(
  @CURRENTAPPUSERID uniqueidentifier,
  @SECURITYFEATUREID uniqueidentifier,
  @SECURITYFEATURETYPE tinyint
)
returns uniqueidentifier
as
begin
  declare @SOURCECODEID uniqueidentifier;

  select top 1 
    @SOURCECODEID = [ID]
  from dbo.[MKTSOURCECODE]
  where [ISDEFAULT] <> 0 
    and [ISACTIVE] <> 0
    and dbo.[UFN_SITEALLOWEDFORUSERONFEATURE](@CURRENTAPPUSERID, [MKTSOURCECODE].[SITEID], @SECURITYFEATUREID, @SECURITYFEATURETYPE) = 1
    -- Layout has at least one source code part.

    and exists (select top 1 1 from dbo.[MKTSOURCECODEITEM] where [MKTSOURCECODEITEM].[SOURCECODEID] = [MKTSOURCECODE].[ID]);

  return @SOURCECODEID;
end