USP_DATAFORMTEMPLATE_VIEW_ENQUEUEUSERNAME

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN
@DATALOADED bit INOUT
@USERNAME nvarchar(128) INOUT

Definition

Copy


CREATE procedure dbo.USP_DATAFORMTEMPLATE_VIEW_ENQUEUEUSERNAME
(
  @ID uniqueidentifier,
  @DATALOADED bit = 0 output,
  @USERNAME nvarchar(128) = null output
)
as
  set nocount on;

  -- be sure to set this, in case the select returns no rows

  set @DATALOADED = 0;

  if exists (select 1 from dbo.APPUSERCLAIMS where APPUSERID = @ID)
  begin
    -- User has been migrated to BBID, so use the email address

    select
      @DATALOADED = 1,
      @USERNAME = [EMAILADDRESS]
    from dbo.[APPUSER]
    where [ID] = @ID;
  end
  else
  begin
    -- User is not migrated and therefore using Active Directory, so use the user name

    select
      @DATALOADED = 1,
      @USERNAME = [USERNAME]
    from dbo.[APPUSER]
    where [ID] = @ID;
  end

  return 0;