USP_DATAFORMTEMPLATE_ADD_CONSTITUENTDATAREVIEWROLLBACK_PHONE_DELETE
The save procedure used by the add dataform template "Constituent Data Review Phone Number Delete Data Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | INOUT | The output parameter indicating the ID of the record added. |
@PHONEID | uniqueidentifier | IN | Input parameter indicating the context ID for the record being added. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@CONSTITUENTDATAREVIEWROLLBACKREASONID | uniqueidentifier | IN | Reason |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_CONSTITUENTDATAREVIEWROLLBACK_PHONE_DELETE
(
@ID uniqueidentifier = null output,
@PHONEID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@CONSTITUENTDATAREVIEWROLLBACKREASONID uniqueidentifier = null
)
as
set nocount on;
if @ID is null
set @ID = newid()
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()
begin try
exec dbo.USP_PHONE_DELETE @PHONEID, @CHANGEAGENTID
declare @AUDITID uniqueidentifier;
-- pull the auditid for what is hopefully the delete we just did
select top 1 @AUDITID = AUDITID
from dbo.PHONEAUDIT
where AUDITRECORDID = @PHONEID
and AUDITTYPECODE = 2
order by AUDITDATE desc;
if @AUDITID is null
raiserror('ERR_COULDNOTFINDAUDIT', 13, 1);
insert into dbo.CONSTITUENTDATAREVIEWROLLBACK
(ID, CONTEXTRECORDID, ROLLBACKAUDITID, SOURCEAUDITID, CONSTITUENTDATAREVIEWROLLBACKREASONID, ADDEDBYID, CHANGEDBYID, DATEADDED, DATECHANGED)
values
(newid(), @PHONEID, @AUDITID, null, @CONSTITUENTDATAREVIEWROLLBACKREASONID, @CHANGEAGENTID, @CHANGEAGENTID, @CURRENTDATE, @CURRENTDATE)
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0