USP_DATAFORMTEMPLATE_ADD_EVENTCOORDINATOR
The save procedure used by the add dataform template "Event Coordinator 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 | Input parameter indicating the context ID for the record being added. |
@CONSTITUENTID | uniqueidentifier | IN | Coordinator |
@SELECTEDEVENTID | uniqueidentifier | IN | Event |
@ISPRIMARY | bit | IN | Is primary |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_EVENTCOORDINATOR
(
@ID uniqueidentifier = null output,
@CHANGEAGENTID uniqueidentifier = null,
@EVENTID uniqueidentifier,
@CONSTITUENTID uniqueidentifier,
@SELECTEDEVENTID uniqueidentifier = null,
@ISPRIMARY bit = null
)
as
set nocount on;
declare @CURRENTDATE datetime;
if (@SELECTEDEVENTID is not null) and (@SELECTEDEVENTID <> '00000000-0000-0000-0000-000000000000')
set @EVENTID = @SELECTEDEVENTID
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;