USP_DATALIST_APPLICATIONUSER_FROMQUERY

List of CMS Roles from query for a particular App User..

Parameters

Parameter Parameter Type Mode Description
@APPUSERID uniqueidentifier IN Input parameter indicating the context ID for the data list.

Definition

Copy


create procedure dbo.USP_DATALIST_APPLICATIONUSER_FROMQUERY
(
    @APPUSERID uniqueidentifier
)
as
    set nocount on;

    declare @ClientUsersId int
    select 
        @ClientUsersId = ClientUsers.ID 
    from dbo.ClientUsers
        join dbo.BBNCUSERMAP on dbo.ClientUsers.UserName=BBNCUSERMAP.BBNCUSERNAME
    where BBNCUSERMAP.ID=@APPUSERID

    SELECT    
        ClientRoles.[ID],
        ClientRoles.[ClientsID] [CLIENTSID],
        ClientRoles.[Name] [NAME],
        ClientRoles.[REQueryName] [QUERYNAME]

    from dbo.ClientRoles
        left outer join dbo.fnUserRoles(@ClientUsersID, 1) fUR on fUR.ClientRolesID = ClientRoles.ID
        left outer join dbo.UserRoles UR on UR.ClientUsersID = @ClientUsersID and UR.ClientRolesID = ClientRoles.ID

    WHERE ClientRoles.Deleted=0 AND ClientRoles.EveryoneRole = 0
        and CAST(ISNULL(fUR.ClientRolesID, 0) as bit) = 1 --member

        and CAST(ISNULL(UR.ManuallyAdded, 0) as bit) = 0 --included by query


    ORDER BY ClientRoles.[Name]