USP_DATAFORMTEMPLATE_EDIT_CAMPAIGNTEAM

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

Parameters

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

Definition

Copy


CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_CAMPAIGNTEAM
(
  @ID uniqueidentifier,
  @ORGTEAMIDSET uniqueidentifier,
  @CHANGEAGENTID uniqueidentifier = null
)
as begin

  set nocount on;

  begin try

    if exists(
        select CTEXIST.ID from dbo.CAMPAIGNTEAM CTEXIST
        inner join dbo.CAMPAIGNTEAM CTEDIT on CTEDIT.ID = @ID and CTEDIT.CAMPAIGNID = CTEXIST.CAMPAIGNID
        where CTEXIST.ORGTEAMIDSET = @ORGTEAMIDSET and CTEXIST.ID <> @ID)
      raiserror('BBERR_CAMPAIGNTEAM_UNIQUECAMPAIGNTEAM',13,1);

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

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

    update 
      dbo.CAMPAIGNTEAM 
    set
      ORGTEAMIDSET = @ORGTEAMIDSET,
      DATECHANGED = @CURRENTDATE,
      CHANGEDBYID = @CHANGEAGENTID
    where
      ID = @ID;

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

  return 0;

end