USP_DATAFORMTEMPLATE_ADD_MKTMARKETINGPLANITEMSPEC

The save procedure used by the add dataform template "Marketing Plan Item Specification 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.
@MARKETINGPLANITEMID uniqueidentifier IN Input parameter indicating the context ID for the record being added.
@PLANITEMSPECCODEID uniqueidentifier IN Section
@TITLE nvarchar(100) IN Title
@NOTES nvarchar(max) IN Notes

Definition

Copy


CREATE procedure dbo.[USP_DATAFORMTEMPLATE_ADD_MKTMARKETINGPLANITEMSPEC]
(
  @ID uniqueidentifier = null output,
  @CHANGEAGENTID uniqueidentifier = null,
  @MARKETINGPLANITEMID uniqueidentifier,
  @PLANITEMSPECCODEID uniqueidentifier = null,
  @TITLE nvarchar(100) = '',
  @NOTES nvarchar(max) = ''
)
as
  set nocount on;

  declare @CURRENTDATE datetime;

  if @ID is null
    set @ID = newid();

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

  set @CURRENTDATE = getdate();

  begin try
    -- create the plan item

    insert into dbo.[MKTMARKETINGPLANITEMSPEC] (
      [ID],
      [MARKETINGPLANITEMID],
      [TITLE],
      [NOTES],
      [PLANITEMSPECCODEID],
      [ADDEDBYID],
      [CHANGEDBYID],
      [DATEADDED],
      [DATECHANGED]
    ) values (
      @ID,
      @MARKETINGPLANITEMID,
      @TITLE,
      @NOTES,
      @PLANITEMSPECCODEID,
      @CHANGEAGENTID,
      @CHANGEAGENTID,
      @CURRENTDATE,
      @CURRENTDATE
    )
  end try

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

  return 0;