USP_DATAFORMTEMPLATE_EDIT_CONTACTREPORT_2

The save procedure used by the edit dataform template "Contact Report Edit".

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
@ACTUALSTARTTIME UDT_HOURMINUTE IN Actual start time
@ACTUALENDTIME UDT_HOURMINUTE IN Actual end time

Definition

Copy

                    CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_CONTACTREPORT_2
                    (
                        @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,
                        @ACTUALSTARTTIME dbo.UDT_HOURMINUTE,
                        @ACTUALENDTIME dbo.UDT_HOURMINUTE
                    ) as begin
                        set nocount on;

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

                        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 = getdate(),
                                ACTUALDATE = @ACTUALDATE,
                                FUNDRAISERID = @OWNERID,
                                INTERACTIONTYPECODEID = @INTERACTIONTYPECODEID,
                                OBJECTIVE = @OBJECTIVE,
                                COMMENT = @COMMENT,
                                PROSPECTPLANSTATUSCODEID = @PROSPECTPLANSTATUSCODEID,
                                INTERACTIONSUBCATEGORYID = @INTERACTIONSUBCATEGORYID,
                                ACTUALSTARTTIME = @ACTUALSTARTTIME,
                                ACTUALENDTIME = @ACTUALENDTIME
                            where
                                ID = @ID

                            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