USP_DATAFORMTEMPLATE_ADD_CONSTITUENTGROUPINTERACTION

The save procedure used by the add dataform template "Constituent Group Interaction Add Form".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier INOUT The output parameter indicating the ID of the record added.
@CURRENTAPPUSERID uniqueidentifier IN Input parameter indicating the ID of the current user.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.
@GROUPCONSTITUENTID uniqueidentifier IN Input parameter indicating the context ID for the record being added.
@INTERACTIONCONSTITUENTID uniqueidentifier IN Constituent
@EXPECTEDDATE datetime IN Expected date
@ACTUALDATE datetime IN Actual date
@FUNDRAISERID uniqueidentifier IN Owner
@INTERACTIONTYPECODEID uniqueidentifier IN Contact method
@OBJECTIVE nvarchar(100) IN Summary
@STATUSCODE tinyint IN Status
@COMMENT nvarchar(max) IN Comment
@EVENTID uniqueidentifier IN Event
@PARTICIPANTS xml IN Participants
@INTERACTIONCATEGORYID uniqueidentifier IN Category
@INTERACTIONSUBCATEGORYID uniqueidentifier IN Subcategory
@SITES xml IN Sites
@EXPECTEDSTARTTIME UDT_HOURMINUTE IN Expected start time
@EXPECTEDENDTIME UDT_HOURMINUTE IN Expected end time
@ISALLDAYEVENT bit IN
@TIMEZONEENTRYID uniqueidentifier IN Time zone
@ACTUALSTARTTIME UDT_HOURMINUTE IN Actual start time
@ACTUALENDTIME UDT_HOURMINUTE IN Actual end time

Definition

Copy


                    CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_CONSTITUENTGROUPINTERACTION
                    (
                        @ID uniqueidentifier = null output,
                        @CURRENTAPPUSERID uniqueidentifier,
                        @CHANGEAGENTID uniqueidentifier = null,
                        @GROUPCONSTITUENTID uniqueidentifier,
                        -- Named INTERACTIONCONSTITUENTID rather than just CONSTITUENTID since the collection

                        -- PARTICIPANTS also has a field called CONSTITUENTID and having the same name used twice

                        -- breaks the simpledatalist.

                        @INTERACTIONCONSTITUENTID uniqueidentifier, 
                        @EXPECTEDDATE datetime = null,
                        @ACTUALDATE datetime = null,
                        @FUNDRAISERID uniqueidentifier = null,
                        @INTERACTIONTYPECODEID uniqueidentifier,
                        @OBJECTIVE nvarchar(100) = '',
                        @STATUSCODE tinyint = 0,
                        @COMMENT nvarchar(max) = '',
                        @EVENTID uniqueidentifier = null
                        @PARTICIPANTS xml = null,
                        @INTERACTIONCATEGORYID uniqueidentifier = null,
                        @INTERACTIONSUBCATEGORYID uniqueidentifier = null,
                        @SITES xml = null,
                        @EXPECTEDSTARTTIME dbo.UDT_HOURMINUTE = null,
                        @EXPECTEDENDTIME dbo.UDT_HOURMINUTE = null,
                        @ISALLDAYEVENT bit = null
                        @TIMEZONEENTRYID uniqueidentifier = null,
                        @ACTUALSTARTTIME dbo.UDT_HOURMINUTE = null,
                        @ACTUALENDTIME dbo.UDT_HOURMINUTE = null
                    )
                    as begin
                        set nocount on;

                        if @ID is null
                            set @ID = newid();

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

                        -- Verify the user has permission to add an interaction to the specific constituent

                        if (dbo.UFN_APPUSER_ISSYSADMIN(@CURRENTAPPUSERID) = 0) and
                            (dbo.UFN_SECURITY_APPUSER_GRANTED_FORM_FORCONSTIT(@CURRENTAPPUSERID, '9554fe6b-5243-401b-bbab-a53fefbe4b98', @INTERACTIONCONSTITUENTID) = 0)
                        begin
                            raiserror ('ERR_NO_PERMISSION_CONSTITUENT',13,1);
                            return 1;
                        end

                        begin try
                            insert into dbo.INTERACTION (
                                ID,
                                ADDEDBYID,
                                CHANGEDBYID,
                                CONSTITUENTID,
                                EXPECTEDDATE,
                                ACTUALDATE,
                                FUNDRAISERID,
                                INTERACTIONTYPECODEID,
                                OBJECTIVE,
                                STATUSCODE,
                                COMMENT,
                                EVENTID,
                                INTERACTIONSUBCATEGORYID,
                                EXPECTEDSTARTTIME,
                                EXPECTEDENDTIME,
                                ISALLDAYEVENT, 
                                TIMEZONEENTRYID,
                                ACTUALSTARTTIME,
                                ACTUALENDTIME
                            ) values (
                                @ID,
                                @CHANGEAGENTID,
                                @CHANGEAGENTID,
                                @INTERACTIONCONSTITUENTID,
                                @EXPECTEDDATE,
                                @ACTUALDATE,
                                @FUNDRAISERID,
                                @INTERACTIONTYPECODEID,
                                @OBJECTIVE,
                                @STATUSCODE,
                                @COMMENT,
                                @EVENTID,
                                @INTERACTIONSUBCATEGORYID,
                                @EXPECTEDSTARTTIME,
                                @EXPECTEDENDTIME,
                                @ISALLDAYEVENT
                                @TIMEZONEENTRYID,
                                @ACTUALSTARTTIME,
                                @ACTUALENDTIME
                            );

                            declare @CURRENTDATE datetime;
                            set @CURRENTDATE = getdate();
                            exec dbo.USP_CONSTITUENTINTERACTION_GETSITES_ADDFROMXML @ID, @SITES, @CHANGEAGENTID, @CURRENTDATE;    

                            exec dbo.USP_INTERACTION_PARTICIPANTS_ADDFROMXML @ID, @PARTICIPANTS, @CHANGEAGENTID;
                        end try
                        begin catch
                            exec dbo.USP_RAISE_ERROR;
                            return 1;
                        end catch;

                        return 0;

                    end;