CEData 1 0-getCEData

From ADF Docs
Revision as of 15:58, 17 September 2010 by Gcronkright (talk | contribs) (Usage:)
Jump to: navigation, search

Attention: Do not change any text in the description, signature, and paramter sections.

Return to CEData_1_0

Description

Returns array of structs for all data matching the Custom Element.

Signature

public array getCEData ( string customElementName, string customElementFieldName, any item, string queryType, string searchValues, string searchFields )

Parameters

Required Name Type Description
required customElementName string
optional customElementFieldName string [Default: ]
  item any [Default: ]
  queryType string [Default: selected]
  searchValues string [Default: ]
  searchFields string [Default: ]

Examples

The getCEDdata function is handy way to get data out of a CommonSpot Custom Element. Making a call to this method will return the data as an Array of Structures for the element specified.

Usage:

Example 1: Use getCEData to return ALL records in a Custom Element:

<cfscript>
     // get data from the "My Element" custom element 
     data = application.ADF.ceData.getCEData(
                       customElementName="My Element"
                      );
</cfscript>

<!---// loop over results (will be all records from the Custom Element)  --->
<cfloop from="1" to="#arrayLen(data)#" index="itm">
    <!---// renders data from the uniqueID and Title fields from the element --->
    <cfoutput>#data[itm].values.uniqueID# #data[itm].values.Title#</cfoutput>
</cfloop>

Example 2: Use getCEData to return only the records that match the provided value for a specific field:

<cfscript>
     // get data from the "My Element" custom element by a uniqueID value
     data = application.ADF.ceData.getCEData(
                       customElementName="My Element",
                       customElementFieldName="uniqueID",
                       item='DF6D9B32-1143-FF53-952805B368AB301B'
                      );
</cfscript>

<!---// loop over results (will only be records that matched the criteria)  --->
<cfloop from="1" to="#arrayLen(data)#" index="itm">
    <!---// renders data from the uniqueID and Title fields from the element --->
    <cfoutput>#data[itm].values.uniqueID# #data[itm].values.Title#</cfoutput>
</cfloop>

Example 3a: Use getCEData(queryType='searchInList') to return the records that match the provided value with any of the items stored in a list as the value of the specified CE field:

A example of two records stored in the "My Element" custom element:  
Record 1:
uniqueID: DF6D9B32-1143-FF53-952805B368AB301B
csPageID: 2011,3010,4808,1660,3710 
Record 2:
uniqueID: 122FFB4E-C95E-77C1-D217186D857F2228
csPageID: 2011,3010,1660,3710
From the example data above, this will only return Record 1
<cfscript>
     // get data from the "My Element" custom element 
     data = application.ADF.ceData.getCEData(
                       customElementName="My Element",
                       customElementFieldName="csPageID",
                       item='4808',
                       queryType='searchInList'
                      );
</cfscript>

<!---// loop over results   --->
<cfloop from="1" to="#arrayLen(data)#" index="itm">
    <!---// renders data from the uniqueID from the element --->
    <cfoutput>#data[itm].values.uniqueID#</cfoutput>
</cfloop>

Example 3b: Use getCEData(queryType='searchInList') to return the records that match the any of the provided values from a list with any of the items stored in a list as the value of the specified CE field:

A example of three records stored in the "My Element" custom element: 
Record 1:
uniqueID: DF6D9B32-1143-FF53-952805B368AB301B
csPageID: 2011,3010,4808,1660,3210 
Record 2:
uniqueID: 122FFB4E-C95E-77C1-D217186D857F2228
csPageID: 2011,3010,1660,3210 
Record 3:
uniqueID: 1BC95CDE-DFBC-047C-2011FC37BE5F6A22
csPageID: 2011,3010,3780,1660,9884
From the example data above, this will return Record 1 and Record 3
<cfscript>
     // get data from the "My Element" custom element 
     data = application.ADF.ceData.getCEData(
                       customElementName="My Element",
                       customElementFieldName="csPageIDs",
                       item='3780,4808',
                       queryType='searchInList'
                      );
</cfscript>

<!---// loop over results (will only be records that matched the criteria)  --->
<cfloop from="1" to="#arrayLen(data)#" index="itm">
    <!---// renders data from the uniqueID --->
    <cfoutput>#data[itm].values.uniqueID#</cfoutput>
</cfloop>