USP_DATAFORMTEMPLATE_EDIT_DESIGNATIONCAMPAIGNFROMDESIGNATION

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

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter indicating the ID of the record being edited.
@CAMPAIGNS xml IN Campaigns
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.

Definition

Copy


                    CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_DESIGNATIONCAMPAIGNFROMDESIGNATION (
                        @ID uniqueidentifier,
                        @CAMPAIGNS xml,
                        @CHANGEAGENTID uniqueidentifier = null
                    ) as begin

                        set nocount on;

                        begin try

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

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

                            --Validate that the dates for a given campaign in the collection do not overlap

                            if dbo.UFN_DESIGNATION_CAMPAIGNDATESOVERLAP(@CAMPAIGNS) = 1
                                raiserror('The dates cannot overlap for a given campaign.', 13, 1);

                            exec dbo.USP_DESIGNATION_CAMPAIGNS_UPDATEFROMXML @ID, @CAMPAIGNS, @CHANGEAGENTID, @CURRENTDATE;

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

                        return 0;

                    end