USP_DATALIST_DATAFORMINSTANCEFIELDS

Displays the fields defined for the given data form instance.

Parameters

Parameter Parameter Type Mode Description
@DATAFORMINSTANCEID uniqueidentifier IN Input parameter indicating the context ID for the data list.

Definition

Copy


CREATE procedure dbo.USP_DATALIST_DATAFORMINSTANCEFIELDS

@DATAFORMINSTANCEID uniqueidentifier

as
    set nocount on;

    with xmlnamespaces ('bb_appfx_commontypes' as common)
    select 
        dataform.fields.value('@FieldID', 'nvarchar(max)') as FIELDID,
        dataform.fields.value('@Caption', 'nvarchar(max)') as CAPTION,
        coalesce(dataform.fields.value('@DataType', 'nvarchar(30)'), 'String') as DATATYPE,
        case
            when dataform.fields.exist('common:CodeTable') = 1 then 
                'Code Table (' 
                + (select UINAME from dbo.CODETABLECATALOG where DBTABLENAME = dataform.fields.value('(common:CodeTable/@CodeTableName)[1]', 'nvarchar(100)'))
                + ')'
            when dataform.fields.exist('common:ValueList') = 1  then 'Value List'
            when dataform.fields.exist('common:SimpleDataList') = 1  then 
                'Simple Data List ('
                + (select UINAME from dbo.SIMPLEDATALISTCATALOG where ID = dataform.fields.value('(common:SimpleDataList/@SimpleDataListID)[1]', 'nvarchar(60)'))
                + ')'
            when dataform.fields.exist('common:Collection') = 1  then 'Collection'
            when dataform.fields.exist('common:SearchList') = 1  then
                'Search List ('
                + (select UINAME from dbo.SEARCHLISTCATALOG where ID = dataform.fields.value('(common:SearchList/@SearchListID)[1]', 'nvarchar(60)'))
                + ')'
            when dataform.fields.exist('common:Link') = 1  then 'Link'
            when dataform.fields.exist('common:File') = 1  then 'File'
            when dataform.fields.exist('common:CreditCard') = 1  then 'Credit Card'
            when dataform.fields.exist('common:Html') = 1  then 'Html'
            else ''
        end as DESCRIPTOR,
        case
            when dataform.fields.exist('common:CodeTable') = 1 then 1 
            when dataform.fields.exist('common:ValueList') = 1 then 2
            when dataform.fields.exist('common:SimpleDataList') = 1 then 3
            when dataform.fields.exist('common:Collection') = 1 then 4
            when dataform.fields.exist('common:SearchList') = 1 then 5
            when dataform.fields.exist('common:Link') = 1  then 6
            when dataform.fields.exist('common:File') = 1  then 7
            when dataform.fields.exist('common:CreditCard') = 1 then 8
            when dataform.fields.exist('common:Html') = 1  then 9
            else 0
        end as DESCRIPTORTYPE,
        case
            when dataform.fields.exist('common:CodeTable') = 1 then 
                (select ID from dbo.CODETABLECATALOG where DBTABLENAME = dataform.fields.value('(common:CodeTable/@CodeTableName)[1]', 'nvarchar(100)'))
            when dataform.fields.exist('common:ValueList') = 1 then null
            when dataform.fields.exist('common:SimpleDataList') = 1 then
                dataform.fields.value('(common:SimpleDataList/@SimpleDataListID)[1]', 'uniqueidentifier')
            when dataform.fields.exist('common:Collection') = 1 then null
            when dataform.fields.exist('common:SearchList') = 1 then 
                dataform.fields.value('(common:SearchList/@SearchListID)[1]', 'uniqueidentifier')
            when dataform.fields.exist('common:Link') = 1  then null
            when dataform.fields.exist('common:File') = 1  then null
            when dataform.fields.exist('common:CreditCard') = 1 then null
            when dataform.fields.exist('common:Html') = 1  then null
            else null
        end as DESCRIPTORID,
        coalesce(dataform.fields.value('@Hidden', 'bit'), 0) as HIDDEN,
        coalesce(dataform.fields.value('@Required', 'bit'), 0) as REQUIRED,
        coalesce(dataform.fields.value('@ReadOnly', 'bit'), 0) as READONLY,
        dbo.UFN_INSTALLEDPRODUCTS_TRANSLATELIST(dataform.fields.query('common:InstalledProductList')) as INSTALLEDPRODUCTSLIST,
        dbo.UFN_INSTALLEDPRODUCTS_OPTIONALPRODUCTSINSTALLED(dataform.fields.query('common:InstalledProductList')) as INSTALLED
    from dbo.DATAFORMINSTANCECATALOG as INSTANCE
        cross apply INSTANCE.FORMUIXML.nodes('common:FormMetaData/common:FormFields/common:FormField') as dataform(fields)
    where INSTANCE.ID = @DATAFORMINSTANCEID