TR_EXCHANGEDOWNLOADPROCESS_AUDIT_DELETE
Definition
Copy
/*
Generated by Blackbaud AppFx Platform
Date: 1/27/2010 6:48:28 PM
Assembly Version: Blackbaud.AppFx.Platform.SqlClr, Version=2.5.465.0, Culture=neutral, PublicKeyToken=null
Copyright Blackbaud
*/
CREATE TRIGGER dbo.TR_EXCHANGEDOWNLOADPROCESS_AUDIT_DELETE ON dbo.EXCHANGEDOWNLOADPROCESS AFTER DELETE NOT FOR REPLICATION
AS
declare @ChangeAgentID uniqueidentifier
declare @AuditKey uniqueidentifier
declare @AuditDate datetime
set nocount on
--peform the audit
if dbo.UFN_AUDITENABLED('EXCHANGEDOWNLOADPROCESS') = 1
begin
-- the audit key is used to associate the rows in the audit table with a single atomic deletion/modification
-- for a delete,
set @AuditKey = NewID()
set @AuditDate = GetDate()
--Get the change agent from the CONTEXT_INFO. If an application wishes to mark a row as deleted by a non-default changeagent then it will have to update the auditrow after the delete using the ID field (where AUDITTYPECODE=2)
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENTFROMCONTEXT @ChangeAgentID output
INSERT INTO dbo.EXCHANGEDOWNLOADPROCESSAUDIT(
AUDITRECORDID,
AUDITKEY,
AUDITCHANGEAGENTID,
AUDITDATE,
AUDITTYPECODE,
[NAME],
[EXCLUDEPERSONAL],
[EXCLUDEPRIVATE],
[EXCLUDECONFIDENTIAL],
[EXCLUDEAUTOREPLY],
[ADDEDBYID],
[CHANGEDBYID],
[DATEADDED],
[DATECHANGED],
[EMAILBATCHAPPUSERID],
[CONTACTBATCHAPPUSERID],
[MAXEMAILBATCHROWCOUNT],
[MAXCONTACTBATCHROWCOUNT],
[DEFAULTCOUNTRYID],
[DEFAULTINTERACTIONTYPECODEID],
[CALENDARITEMBATCHAPPUSERID],
[MAXCALENDARITEMBATCHROWCOUNT],
[DEFAULTINFOSOURCECODEID]
)
SELECT
ID,
@AuditKey,
@ChangeAgentID,
@AuditDate,
2, --Before DELETE
[NAME],
[EXCLUDEPERSONAL],
[EXCLUDEPRIVATE],
[EXCLUDECONFIDENTIAL],
[EXCLUDEAUTOREPLY],
[ADDEDBYID],
[CHANGEDBYID],
[DATEADDED],
[DATECHANGED],
[EMAILBATCHAPPUSERID],
[CONTACTBATCHAPPUSERID],
[MAXEMAILBATCHROWCOUNT],
[MAXCONTACTBATCHROWCOUNT],
[DEFAULTCOUNTRYID],
[DEFAULTINTERACTIONTYPECODEID],
[CALENDARITEMBATCHAPPUSERID],
[MAXCALENDARITEMBATCHROWCOUNT],
[DEFAULTINFOSOURCECODEID]
FROM DELETED
end