USP_DATAFORMTEMPLATE_ADD_MKTVENDOR_PRELOAD

The load procedure used by the edit dataform template "Marketing Vendor Add Form"

Parameters

Parameter Parameter Type Mode Description
@ADDRESS_COUNTRYID uniqueidentifier INOUT Country
@CONTACT_ADDRESS_COUNTRYID uniqueidentifier INOUT Country
@SERVICETYPES xml INOUT Available service types
@SERVICES xml INOUT Available services
@SERVICETYPECODE tinyint IN Input parameter indicating the context ID for the record being added.
@CONSTITUENTTYPE int INOUT Constituent type
@CURRENTAPPUSERID uniqueidentifier IN Input parameter indicating the ID of the current user.
@SITES xml INOUT Sites
@SITEREQUIRED bit INOUT Site required
@DEFAULT_COUNTRYID uniqueidentifier INOUT

Definition

Copy


CREATE procedure dbo.[USP_DATAFORMTEMPLATE_ADD_MKTVENDOR_PRELOAD]
(
  @ADDRESS_COUNTRYID uniqueidentifier = null output,
  @CONTACT_ADDRESS_COUNTRYID uniqueidentifier = null output,
  @SERVICETYPES xml = null output,
  @SERVICES xml = null output,
  @SERVICETYPECODE tinyint,
  @CONSTITUENTTYPE int = null output,
  @CURRENTAPPUSERID uniqueidentifier = null,
  @SITES xml = null output,
  @SITEREQUIRED bit = null output,
  @DEFAULT_COUNTRYID uniqueidentifier = null output
)
as
  set nocount on;

  set @ADDRESS_COUNTRYID = dbo.[UFN_COUNTRY_GETDEFAULT]();
  set @CONTACT_ADDRESS_COUNTRYID = dbo.[UFN_COUNTRY_GETDEFAULT]();
  set @DEFAULT_COUNTRYID = dbo.[UFN_COUNTRY_GETDEFAULT]();

  declare @SERVICETYPESTABLE table ([SERVICETYPECODE] tinyint not null);

  -- this is done this way so as to be extendable in the future, when vendors are 

  -- shared with other product lines

  -- logic like "if the product is BBDM, allow lists and creatives; if the product

  -- is PE, allow tickets, etc." would go here (and appropriate values would be

  -- added to the enumeration to represent those service types)


  insert into @SERVICETYPESTABLE values (1); -- creatives

  insert into @SERVICETYPESTABLE values (2); -- lists

  insert into @SERVICETYPESTABLE values (3); -- public media


  set @SERVICETYPES = (
    select 
      [SERVICETYPECODE]
    from @SERVICETYPESTABLE
    for xml raw('ITEM'), type, elements, root('SERVICETYPES'), binary base64);

  set @SERVICES = (
    select 
      [MKTSERVICE].[ID],
      [MKTSERVICECATEGORYCODE].[DESCRIPTION] as [CATEGORY],
      [MKTSERVICE].[NAME],
      [MKTSERVICE].[SERVICECATEGORYCODEID]
    from dbo.[MKTSERVICE] 
    inner join dbo.[MKTSERVICECATEGORYCODE] 
    on [MKTSERVICECATEGORYCODE].[ID] = [MKTSERVICE].[SERVICECATEGORYCODEID]
    order by [MKTSERVICECATEGORYCODE].[DESCRIPTION], [MKTSERVICE].[SERVICECATEGORYCODEID], [MKTSERVICE].[NAME]
    for xml raw('ITEM'), type, elements, root('SERVICES'), binary base64);

  set @SITES = dbo.[UFN_VENDOR_GETDEFAULTSITES](@CURRENTAPPUSERID, 'D6DCE820-315F-4eb3-A673-63103C0ECB63');
  set @SITEREQUIRED = dbo.[UFN_SITEREQUIREDFORUSERONFEATURE](@CURRENTAPPUSERID, '05dc9052-4d2d-499b-a037-9726445c7842', 1);

  set @CONSTITUENTTYPE = 1;

  return 0;