USP_DATAFORMTEMPLATE_ADD_EVENTCOORDINATORBYCONSTITUENT

The save procedure used by the add dataform template "Event Coordinator From Constituent 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.
@EVENTID uniqueidentifier IN Event
@CONSTITUENTID uniqueidentifier IN Input parameter indicating the context ID for the record being added.
@ISPRIMARY bit IN Is primary

Definition

Copy


                    CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_EVENTCOORDINATORBYCONSTITUENT
                    (
                        @ID uniqueidentifier = null output,
                        @CHANGEAGENTID uniqueidentifier = null,    
                        @EVENTID uniqueidentifier,
                        @CONSTITUENTID uniqueidentifier,
                        @ISPRIMARY bit = null
                    )
                    as
                        set nocount on;

                        declare @CURRENTDATE datetime;

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

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

                            set @CURRENTDATE = getdate();

                            --remove the event's primary coordinator if this coordinator has ISPRIMARY set to 1.

                            if @ISPRIMARY = 1
                            begin
                              update dbo.EVENTCOORDINATOR 
                              set
                                ISPRIMARY = 0
                              where 
                                EVENTID = @EVENTID and
                                ISPRIMARY = 1
                            end

                            insert into dbo.EVENTCOORDINATOR 
                                (ID, EVENTID, CONSTITUENTID, ISPRIMARY, ADDEDBYID, CHANGEDBYID, DATEADDED, DATECHANGED)
                            values
                                (@ID, @EVENTID, @CONSTITUENTID, @ISPRIMARY, @CHANGEAGENTID, @CHANGEAGENTID, @CURRENTDATE, @CURRENTDATE)

                        end try

                        begin catch
                            exec dbo.USP_RAISE_ERROR;
                            return 1;
                        end catch

                        return 0;