USP_DATAFORMTEMPLATE_ADD_DONORCHALLENGEDESIGNATIONMAP
The save procedure used by the add dataform template "Donor Challenge Designation Map 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. |
@CURRENTAPPUSERID | uniqueidentifier | IN | Input parameter indicating the ID of the current user. |
@DONORCHALLENGEID | uniqueidentifier | IN | Input parameter indicating the context ID for the record being added. |
@ORIGINALDESIGNATIONID | uniqueidentifier | IN | Original gift designation |
@MATCHINGDESIGNATIONID | uniqueidentifier | IN | Matching funds designation |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_DONORCHALLENGEDESIGNATIONMAP
(
@ID uniqueidentifier = null output,
@CHANGEAGENTID uniqueidentifier = null,
@CURRENTAPPUSERID uniqueidentifier,
@DONORCHALLENGEID uniqueidentifier,
@ORIGINALDESIGNATIONID uniqueidentifier,
@MATCHINGDESIGNATIONID uniqueidentifier = null
)
as
begin
set nocount on;
declare @CURRENTDATE datetime = getdate();
if @ID is null
set @ID = newid();
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
begin try
declare @TYPECODE as tinyint;
select @TYPECODE = TYPECODE from dbo.DONORCHALLENGE where ID = @DONORCHALLENGEID;
insert into dbo.DONORCHALLENGEDESIGNATIONMAP
(
ID,
DONORCHALLENGEID,
DESIGNATIONID,
MATCHINGDESIGNATIONID,
ADDEDBYID,
CHANGEDBYID,
DATEADDED,
DATECHANGED
)
values
(
@ID,
@DONORCHALLENGEID,
@ORIGINALDESIGNATIONID,
case when @TYPECODE = 1 then null else @MATCHINGDESIGNATIONID end,
@CHANGEAGENTID,
@CHANGEAGENTID,
@CURRENTDATE,
@CURRENTDATE
)
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0
end