USP_DATAFORMTEMPLATE_EDIT_CONTACTREPORTFILE
The save procedure used by the edit dataform template "Contact Report File 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. |
| @ACTUALDATE | datetime | IN | Actual date |
| @OWNERID | uniqueidentifier | IN | Owner |
| @INTERACTIONTYPECODEID | uniqueidentifier | IN | Contact Method |
| @OBJECTIVE | nvarchar(100) | IN | Objective |
| @PROSPECTPLANSTATUSCODEID | uniqueidentifier | IN | Stage |
| @COMMENT | nvarchar(max) | IN | Comment |
| @ADDITIONALFUNDRAISERS | xml | IN | Additional solicitors |
| @PARTICIPANTS | xml | IN | Participants |
| @INTERACTIONCATEGORYID | uniqueidentifier | IN | Category |
| @INTERACTIONSUBCATEGORYID | uniqueidentifier | IN | Subcategory |
| @NEXTSTEPID | uniqueidentifier | IN | ID |
| @EDITNEXTSTEP | bit | IN | Edit next step information |
| @NEXTSTEPOBJECTIVE | nvarchar(100) | IN | Objective |
| @NEXTSTEPOWNERID | uniqueidentifier | IN | Owner |
| @NEXTSTEPSTATUSCODE | tinyint | IN | Status |
| @NEXTSTEPEXPECTEDDATE | datetime | IN | Expected date |
| @NEXTSTEPACTUALDATE | datetime | IN | Actual date |
| @ACTUALSTARTTIME | UDT_HOURMINUTE | IN | Actual start time |
| @ACTUALENDTIME | UDT_HOURMINUTE | IN | Actual end time |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_CONTACTREPORTFILE
(
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@ACTUALDATE datetime,
@OWNERID uniqueidentifier,
@INTERACTIONTYPECODEID uniqueidentifier,
@OBJECTIVE nvarchar(100),
@PROSPECTPLANSTATUSCODEID uniqueidentifier,
@COMMENT nvarchar(max),
@ADDITIONALFUNDRAISERS xml,
@PARTICIPANTS xml,
@INTERACTIONCATEGORYID uniqueidentifier,
@INTERACTIONSUBCATEGORYID uniqueidentifier,
@NEXTSTEPID uniqueidentifier,
@EDITNEXTSTEP bit,
@NEXTSTEPOBJECTIVE nvarchar(100),
@NEXTSTEPOWNERID uniqueidentifier,
@NEXTSTEPSTATUSCODE tinyint,
@NEXTSTEPEXPECTEDDATE datetime,
@NEXTSTEPACTUALDATE datetime,
@ACTUALSTARTTIME dbo.UDT_HOURMINUTE,
@ACTUALENDTIME dbo.UDT_HOURMINUTE
) as begin
set nocount on;
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
declare @CURRENTDATE datetime;
set @CURRENTDATE = getdate();
begin try
-- Clear the owner from additional fundraisers in case the new owner was an additional fundraiser
-- but isn't anymore. If they weren't cleared, a constraint violation would occur. If the owner
-- is still an additional fundraiser, it will be caught when updating the additional fundraisers.
delete from dbo.INTERACTIONADDITIONALFUNDRAISER where INTERACTIONID = @ID and FUNDRAISERID = @OWNERID;
update dbo.INTERACTION set
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE,
ACTUALDATE = @ACTUALDATE,
FUNDRAISERID = @OWNERID,
INTERACTIONTYPECODEID = @INTERACTIONTYPECODEID,
OBJECTIVE = @OBJECTIVE,
STATUSCODE = 2,
COMMENT = @COMMENT,
PROSPECTPLANSTATUSCODEID = @PROSPECTPLANSTATUSCODEID,
INTERACTIONSUBCATEGORYID = @INTERACTIONSUBCATEGORYID,
ACTUALSTARTTIME = @ACTUALSTARTTIME,
ACTUALENDTIME = @ACTUALENDTIME
where
ID = @ID;
if @EDITNEXTSTEP = 1
begin
update dbo.INTERACTION
set
OBJECTIVE = @NEXTSTEPOBJECTIVE,
FUNDRAISERID = @NEXTSTEPOWNERID,
STATUSCODE = @NEXTSTEPSTATUSCODE,
EXPECTEDDATE = @NEXTSTEPEXPECTEDDATE,
ACTUALDATE = @NEXTSTEPACTUALDATE,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE
where
INTERACTION.ID = @NEXTSTEPID;
end
exec dbo.USP_INTERACTION_ADDITIONALFUNDRAISERS_UPDATEFROMXML @ID, @ADDITIONALFUNDRAISERS, @CHANGEAGENTID;
-- If the step isn't an interaction, clear any participants. Otherwise, just update them.
if @INTERACTIONTYPECODEID is null
delete from dbo.INTERACTIONPARTICIPANT where INTERACTIONID = @ID;
else
exec dbo.USP_INTERACTION_PARTICIPANTS_UPDATEFROMXML @ID, @PARTICIPANTS, @CHANGEAGENTID;
end try
begin catch
exec dbo.USP_RAISE_ERROR;
return 1;
end catch;
return 0;
end