USP_DATAFORMTEMPLATE_ADD_FEEDALERTINSTANCEAPPUSER
The save procedure used by the add dataform template "Custom Email Alert Instance Single User Add Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | INOUT | The output parameter indicating the ID of the record added. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@INSTANCEID | uniqueidentifier | IN | Input parameter indicating the context ID for the record being added. |
@USERID | uniqueidentifier | IN | Application user |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_FEEDALERTINSTANCEAPPUSER
(
@ID uniqueidentifier = null output,
@CHANGEAGENTID uniqueidentifier = null,
@INSTANCEID uniqueidentifier,
@USERID uniqueidentifier
)
as
set nocount on;
begin try
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
declare @CHANGEDATE datetime;
set @CHANGEDATE = getdate();
if @ID is null
set @ID = newid();
declare @OLDID uniqueidentifier;
set @OLDID = null;
select @OLDID = ID from dbo.APPUSERFEEDALERTINSTANCE where FEEDALERTINSTANCEID = @INSTANCEID and APPUSERID = @USERID;
if not @OLDID is null
set @ID = @OLDID;
else
insert into dbo.APPUSERFEEDALERTINSTANCE(ID, FEEDALERTINSTANCEID, APPUSERID, DATELASTPROCESSED, ADDEDBYID, CHANGEDBYID, DATEADDED, DATECHANGED)
values(@ID, @INSTANCEID, @USERID, getdate(), @CHANGEAGENTID, @CHANGEAGENTID, @CHANGEDATE, @CHANGEDATE);
end try
begin catch
exec dbo.USP_RAISE_ERROR;
return 1;
end catch
return 0;