USP_DATAFORMTEMPLATE_ADD_CONSTITUENTGROUPAPPEAL

The save procedure used by the add dataform template "Constituent Group Appeal 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.
@GROUPID uniqueidentifier IN Input parameter indicating the context ID for the record being added.
@CONSTITUENTID uniqueidentifier IN Constituent
@APPEALID uniqueidentifier IN Appeal
@MKTSEGMENTATIONID uniqueidentifier IN Mailing
@SOURCECODE nvarchar(50) IN Source code
@DATESENT datetime IN Date sent
@COMMENTS nvarchar(50) IN Comments
@MKTPACKAGEID uniqueidentifier IN Package
@CURRENTAPPUSERID uniqueidentifier IN Input parameter indicating the ID of the current user.

Definition

Copy


                    CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_CONSTITUENTGROUPAPPEAL
                    (
                        @ID uniqueidentifier = null output,
                        @CHANGEAGENTID uniqueidentifier = null,    
            @GROUPID uniqueidentifier,
                        @CONSTITUENTID uniqueidentifier = null,
                        @APPEALID uniqueidentifier,
                        @MKTSEGMENTATIONID uniqueidentifier = null,
                        @SOURCECODE nvarchar(50) = null,
                        @DATESENT datetime = null,
                        @COMMENTS nvarchar(50) = null,
                        @MKTPACKAGEID uniqueidentifier = null,
            @CURRENTAPPUSERID uniqueidentifier
                    )
                    as
                    begin
                        set nocount on;

                        declare @CURRENTDATE datetime;

                        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 appeal to the specific constituent

                        if (dbo.UFN_APPUSER_ISSYSADMIN(@CURRENTAPPUSERID) = 0) and
                       (dbo.UFN_SECURITY_APPUSER_GRANTED_FORM_FORCONSTIT(@CURRENTAPPUSERID, '63a8e492-c7fa-4934-9a58-cc50b46a96fe', @CONSTITUENTID) = 0)
                        begin
                            raiserror ('ERR_NO_PERMISSION_CONSTITUENT',13,1);
                            return 1;
                        end


                        set @CURRENTDATE = getdate();

                        begin try                        

                        insert into dbo.CONSTITUENTAPPEAL
                            (ID,CONSTITUENTID,APPEALID,MKTSEGMENTATIONID,SOURCECODE,DATESENT,MKTPACKAGEID,COMMENTS,ADDEDBYID,CHANGEDBYID,DATEADDED,DATECHANGED)
                        VALUES
                            (@ID,@CONSTITUENTID,@APPEALID,@MKTSEGMENTATIONID,@SOURCECODE,@DATESENT,@MKTPACKAGEID,@COMMENTS,@CHANGEAGENTID,@CHANGEAGENTID,@CURRENTDATE,@CURRENTDATE);

                        end try

                        begin catch
                            exec dbo.USP_RAISE_ERROR
                            return 1
                        end catch

                        return 0

                    end