USP_RECORDSECURITYIDMAP_GETMAPPINGFUNCTIONS

Returns the list of RecordTypes and the mapping functions that will map an ID of that recordtype to an ID of the TORECORDTYPE that is passed in.

Parameters

Parameter Parameter Type Mode Description
@TORECORDTYPE nvarchar(50) IN

Definition

Copy


CREATE procedure dbo.[USP_RECORDSECURITYIDMAP_GETMAPPINGFUNCTIONS]
(
  @TORECORDTYPE nvarchar(50)
)
as
    set nocount on;

    /* Returning TORECORDTYPE redundantly on purpose as a convenience for site security code. */
    select
    [RECORDSECURITYIDMAP].[FROMRECORDTYPE],
    [RECORDSECURITYIDMAP].[MAPPINGFUNCTION],
    [RECORDSECURITYIDMAP].[ISTVF],
    [RECORDSECURITYIDMAP].[TORECORDTYPE],
    [RECORDSECURITYIDMAP].[MAPPINGFUNCTIONFORQUERY],
    case 
        when exists (
                select 1
                from sys.columns
                inner join sys.objects
                    on sys.objects.object_id = sys.columns.object_id
                where sys.objects.name = [RECORDSECURITYIDMAP].[MAPPINGFUNCTIONFORQUERY]
                    and sys.columns.name = 'CONSTITUENTID'
                )
            then cast('CONSTITUENTID' as varchar(128))
            else cast('ID' as varchar(128))
    end as [MAPPINGFUNCTIONFORQUERYCOLUMNNAME],
    [RECORDSECURITYIDMAP].[NULLSECURITYVIEW]
    from dbo.[RECORDSECURITYIDMAP]
    where [RECORDSECURITYIDMAP].[TORECORDTYPE] = @TORECORDTYPE
    order by [RECORDSECURITYIDMAP].[FROMRECORDTYPE];

    return 0;