USP_DATAFORMTEMPLATE_ADD_PROSPECTPLANSECONDARYFUNDRAISER
The save procedure used by the add dataform template "Prospect Plan Secondary Fundraiser Add Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | INOUT | The output parameter indicating the ID of the record added. |
@PROSPECTPLANID | 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. |
@FUNDRAISERID | uniqueidentifier | IN | Solicitor |
@SOLICITORROLECODEID | uniqueidentifier | IN | Role |
@DATEFROM | datetime | IN | Start date |
@DATETO | datetime | IN | End date |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_PROSPECTPLANSECONDARYFUNDRAISER
(
@ID uniqueidentifier = null output,
@PROSPECTPLANID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@FUNDRAISERID uniqueidentifier,
@SOLICITORROLECODEID uniqueidentifier = null,
@DATEFROM datetime = null,
@DATETO datetime = 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
-- handle inserting the data
insert into dbo.SECONDARYFUNDRAISER
(ID, PROSPECTPLANID, FUNDRAISERID, SOLICITORROLECODEID, DATEFROM, DATETO, ADDEDBYID, CHANGEDBYID, DATEADDED, DATECHANGED)
values
(@ID, @PROSPECTPLANID, @FUNDRAISERID, @SOLICITORROLECODEID, @DATEFROM, @DATETO, @CHANGEAGENTID, @CHANGEAGENTID, @CURRENTDATE, @CURRENTDATE);
-- Assign this fundraiser to any steps tied to plan outlines that have no fundraiser assigned
update dbo.INTERACTION set
FUNDRAISERID = @FUNDRAISERID,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE
from
dbo.PLANOUTLINESTEP
where
PLANOUTLINESTEP.ID = PLANOUTLINESTEPID
and PLANOUTLINESTEP.FUNDRAISERROLECODE = 3
and FUNDRAISERID is null
and PROSPECTPLANID = @PROSPECTPLANID;
end try
begin catch
exec dbo.USP_RAISE_ERROR;
return 1;
end catch
return 0