USP_DATALIST_APPEAL_APPEALEMAILLIST

Returns the IDs of appeal email lists for the specified appeal. Ensures that at least one exists.

Parameters

Parameter Parameter Type Mode Description
@APPEALID int IN Input parameter indicating the context ID for the data list.
@CMSUSERID int IN CMS User ID

Definition

Copy


CREATE procedure dbo.USP_DATALIST_APPEAL_APPEALEMAILLIST
(
@APPEALID int,
@CMSUSERID int
)
as
    set nocount on;

  if not EXISTS(select 1
                from dbo.EMAILLIST EL
                where ORIGIN = 5 AND CAST(Options as nvarchar(20)) = CAST(@APPEALID as nvarchar(20)) and Deleted = 0)
  begin
    --Create a list for this appeal

    declare @APPEALIDTEXT nvarchar(20)
    set @APPEALIDTEXT = CAST(@APPEALID as nvarchar(20))

    declare @DEFAULTSITEID int
    select @DEFAULTSITEID = Value from dbo.Setting where ID = 1

    declare @NAME nvarchar(50)
    set @NAME = 'System list for Appeal ' + @APPEALIDTEXT

    insert into dbo.EmailList(Name, Options, Origin, OwnerID, SystemList, ClientSitesID, ClientsID, DataSourceID, Guid, AcquiredStatus, AcquiredDate)
    values(@NAME, @APPEALIDTEXT, 5, @CMSUSERID, 1, @DEFAULTSITEID, 1, 400, NEWID(), 0, null)
  end

  select EL.ID
  from dbo.EMAILLIST EL
  where ORIGIN = 5 AND CAST(Options as nvarchar(20)) = CAST(@APPEALID as nvarchar(20)) and Deleted = 0