USP_DATAFORMTEMPLATE_ADD_CONSTITUENTGROUPCORRESPONDENCE
The save procedure used by the add dataform template "Constituent Group Correspondence Add Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | INOUT | The output parameter indicating the ID of the record added. |
@GROUPID | uniqueidentifier | IN | Input parameter indicating the context ID for the record being added. |
@CONSTITUENTID | uniqueidentifier | IN | Constituent |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@CORRESPONDENCECODEID | uniqueidentifier | IN | Correspondence code |
@DATESENT | datetime | IN | Date sent |
@COMMENTS | nvarchar(255) | IN | Comments |
@CURRENTAPPUSERID | uniqueidentifier | IN | Input parameter indicating the ID of the current user. |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_CONSTITUENTGROUPCORRESPONDENCE
(
@ID uniqueidentifier = null output,
@GROUPID uniqueidentifier,
@CONSTITUENTID uniqueidentifier = null,
@CHANGEAGENTID uniqueidentifier = null,
@CORRESPONDENCECODEID uniqueidentifier = null,
@DATESENT datetime = null,
@COMMENTS nvarchar(255) = '',
@CURRENTAPPUSERID uniqueidentifier
)
as
set nocount on;
-- Verify the user has permission to add a correspondence to the specific constituent
if (dbo.UFN_APPUSER_ISSYSADMIN(@CURRENTAPPUSERID) = 0) and
(dbo.UFN_SECURITY_APPUSER_GRANTED_FORM_FORCONSTIT(@CURRENTAPPUSERID, 'e8062f9a-bdc1-4840-b619-bad24adef491', @CONSTITUENTID) = 0)
begin
raiserror ('ERR_NO_PERMISSION_CONSTITUENT',13,1);
return 1;
end
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();
insert into dbo.CONSTITUENTCORRESPONDENCE
(
ID,
CONSTITUENTID,
CORRESPONDENCECODEID,
DATESENT,
COMMENTS,
ADDEDBYID,
CHANGEDBYID,
DATEADDED,
DATECHANGED
)
values
(
@ID,
@CONSTITUENTID,
@CORRESPONDENCECODEID,
@DATESENT,
@COMMENTS,
@CHANGEAGENTID,
@CHANGEAGENTID,
@CURRENTDATE,
@CURRENTDATE
);
end try
begin catch
exec dbo.USP_RAISE_ERROR;
return 1;
end catch
return 0;