USP_SIMPLEDATALIST_COMMUNICATIONSMERGEFIELD

Returns a list of the available merge fields based on a given export definition, including the default 'Merge fields' value as a starting value and the 'More fields' value at the end of the list.

Parameters

Parameter Parameter Type Mode Description
@EXPORTDEFINITIONID uniqueidentifier IN
@QUERYVIEWCATALOGID uniqueidentifier IN

Definition

Copy


CREATE procedure dbo.USP_SIMPLEDATALIST_COMMUNICATIONSMERGEFIELD
(
    @EXPORTDEFINITIONID uniqueidentifier,
    @QUERYVIEWCATALOGID uniqueidentifier = null
)
as begin
    set nocount on;

    declare @LIST table (SEQUENCE int identity(0, 1), VALUE nvarchar(255), LABEL nvarchar(255));

    insert into @LIST (VALUE, LABEL)
    values 
        ('MERGEFIELDS', 'Merge fields');

    -- select statement copied from ExportDefinitionOutputField.SimpleDataList.xml

    insert into @LIST (VALUE, LABEL)
        select
            [QUERYFIELD] as [VALUE],
            [NAME] as [LABEL]
          from
            dbo.[MKTEXPORTDEFINITIONOUTPUTFIELD]
          where
            [EXPORTDEFINITIONID] = @EXPORTDEFINITIONID
          and
            (@QUERYVIEWCATALOGID is null or [QUERYVIEWCATALOGID] = @QUERYVIEWCATALOGID)
          order by
            [QUERYVIEWCATALOGID], [SEQUENCE];

    -- Leaving 'More fields' out until the ExportDefinition.Edit.xml spec is converted to WebUI

    -- Uncommenting this insert, will offer the Appeal Mailing Setup Letter Add/Edit forms

    --    the ability to make editable copies of the standard appeal mailing export definitions

    --    allowing them to add more fields to the export

/*    
    insert into @LIST (VALUE, LABEL)
    values
        ('MOREFIELDS', 'More fields');
*/

    select 
        VALUE
        LABEL
    from @LIST
    order by SEQUENCE asc;

    return 0;
end