USP_DATAFORMTEMPLATE_EDIT_CAMPAIGN

The save procedure used by the edit dataform template "Campaign Edit Form".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter indicating the ID of the record being edited.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.
@NAME nvarchar(100) IN Name
@DESCRIPTION nvarchar(300) IN Description
@USERID nvarchar(100) IN Lookup ID
@CAMPAIGNTYPECODEID uniqueidentifier IN Type
@SITES xml IN Sites
@STARTDATE datetime IN Start date
@ENDDATE datetime IN End date
@CURRENTAPPUSERID uniqueidentifier IN Input parameter indicating the ID of the current user.

Definition

Copy


                    CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_CAMPAIGN (
                        @ID uniqueidentifier,
                        @CHANGEAGENTID uniqueidentifier = null,
                        @NAME nvarchar(100),
                        @DESCRIPTION nvarchar(300),
                        @USERID nvarchar(100),
                        @CAMPAIGNTYPECODEID uniqueidentifier,
                        @SITES xml,
                        @STARTDATE datetime,
                        @ENDDATE datetime,
                        @CURRENTAPPUSERID uniqueidentifier
                    ) as begin

                        set nocount on;

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

                        declare @CURRENTDATE datetime;
                        set @CURRENTDATE = getdate();

                        begin try
                            if @SITES is null
                                begin 
                                if dbo.UFN_SITEREQUIREDFORUSER(@CURRENTAPPUSERID) = 1 
                                    begin
                                    raiserror('Site is required.',13,1)
                                    return
                                end
                            end

                            exec dbo.USP_CAMPAIGNSITE_VALIDATESITES @SITES

                            update
                                dbo.CAMPAIGN
                            set
                                NAME = @NAME,
                                DESCRIPTION = @DESCRIPTION,
                                USERID = @USERID,
                                CAMPAIGNTYPECODEID = @CAMPAIGNTYPECODEID,
                                STARTDATE = dbo.UFN_DATE_GETEARLIESTTIME(@STARTDATE),
                                ENDDATE = dbo.UFN_DATE_GETEARLIESTTIME(@ENDDATE),
                                DATECHANGED = @CURRENTDATE,
                                CHANGEDBYID = @CHANGEAGENTID
                            where
                                ID = @ID;

                            exec dbo.USP_CAMPAIGN_GETSITES_UPDATEFROMXML @ID, @SITES, @CHANGEAGENTID, @CURRENTDATE
                        end try

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

                        return 0;

                    end