USP_DATAFORMTEMPLATE_EDIT_DESIGNATIONCAMPAIGNFROMCAMPAIGN

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

Parameters

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

Definition

Copy


                    CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_DESIGNATIONCAMPAIGNFROMCAMPAIGN (
                        @ID uniqueidentifier,
                        @DESIGNATIONS 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 designation in the collection do not overlap

                            if dbo.UFN_CAMPAIGN_DESIGNATIONDATESOVERLAP(@DESIGNATIONS) = 1
                                raiserror('The dates cannot overlap for a given designation.', 13, 1);

                            exec dbo.USP_CAMPAIGN_DESIGNATIONS_UPDATEFROMXML @ID, @DESIGNATIONS, @CHANGEAGENTID, @CURRENTDATE;
                        end try
                        begin catch
                            exec dbo.USP_RAISE_ERROR;
                            return 1;
                        end catch

                        return 0;

                    end