USP_DATAFORMTEMPLATE_EDIT_DONORLIFECYCLECRITERIA

The save procedure used by the edit dataform template "Donor Lifecycle Criteria Edit Data Form".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter indicating the ID of the record being edited.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.
@DONORPERIOD int IN Number of years
@DONORASOFDATE datetime IN As of date
@MIDLEVELDONORGIFTAMOUNT int IN Mid-level donor amount
@USECONSECUTIVELOYALYEARS bit IN Constituents with revenue activity within the specified number of consecutive years are 'Loyal donors'
@CONSECUTIVELOYALYEARS int IN Number of years
@USEMULTIPLELOYALYEARS bit IN Constituents with revenue activity within the specified number of years in a defined range are 'Loyal donors'
@LOYALDONORMULTIYEARVALUE int IN out of the past
@LOYALDONORMULTIYEARRANGE int IN
@DONORFILTERTYPECODE int IN DONORFILTERTYPECODE
@CONSIDERRECOGNITION bit IN Consider recognition credits when calculating revenue

Definition

Copy


CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_DONORLIFECYCLECRITERIA (
    @ID uniqueidentifier,
    @CHANGEAGENTID uniqueidentifier = null,
    @DONORPERIOD int,
    @DONORASOFDATE datetime,
    @MIDLEVELDONORGIFTAMOUNT int,
    @USECONSECUTIVELOYALYEARS bit,
    @CONSECUTIVELOYALYEARS int
    @USEMULTIPLELOYALYEARS bit,
    @LOYALDONORMULTIYEARVALUE int,
    @LOYALDONORMULTIYEARRANGE int,
    @DONORFILTERTYPECODE int,
    @CONSIDERRECOGNITION bit
)
as

    set nocount on;

    if @CHANGEAGENTID is null  
        exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output

    declare @CURRENTDATE datetime
    set @CURRENTDATE = getdate()

    begin try
        update 
            dbo.REVENUELIFECYCLECRITERIA 
        set
            DONORPERIOD = @DONORPERIOD,
            DONORASOFDATE = @DONORASOFDATE,
            MIDLEVELDONORGIFTAMOUNT = @MIDLEVELDONORGIFTAMOUNT,
            USECONSECUTIVELOYALYEARS = @USECONSECUTIVELOYALYEARS,
            CONSECUTIVELOYALYEARS = @CONSECUTIVELOYALYEARS,
            USEMULTIPLELOYALYEARS = @USEMULTIPLELOYALYEARS,
            LOYALDONORMULTIYEARVALUE = @LOYALDONORMULTIYEARVALUE,
            LOYALDONORMULTIYEARRANGE = @LOYALDONORMULTIYEARRANGE,
            DONORFILTERTYPECODE = @DONORFILTERTYPECODE,
            CONSIDERRECOGNITION = @CONSIDERRECOGNITION,
            CHANGEDBYID = @CHANGEAGENTID,
            DATECHANGED = @CURRENTDATE
        where 
            ID = @ID
    end try
    begin catch
        exec dbo.USP_RAISE_ERROR
        return 1
    end catch

return 0;