Difference between revisions of "CEData 1 0-getCEData"

From ADF Docs
Jump to: navigation, search
(Usage:)
(Usage:)
Line 82: Line 82:
  
 
=== Usage: ===
 
=== Usage: ===
Example 1: Use getCEData to get ALL records in a Custom Element:  
+
Example 1: Use getCEData to return ALL records in a Custom Element:  
 
<source lang="cfm">
 
<source lang="cfm">
 
<cfscript>
 
<cfscript>
Line 98: Line 98:
 
</source>
 
</source>
  
Example 2: Use getCEData to get only the records that match the provided value for a specific field:  
+
Example 2: Use getCEData to return only the records that match the provided value for a specific field:  
 
<source lang="cfm">
 
<source lang="cfm">
 
<cfscript>
 
<cfscript>
Line 116: Line 116:
 
</source>
 
</source>
  
Example 3a: Use getCEData(queryType='compareInList') to return the records that match the provided value for a specific field:  
+
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:
  
 
<source lang="cfm">
 
<source lang="cfm">
Line 126: Line 126:
 
uniqueID: 122FFB4E-C95E-77C1-D217186D857F2228
 
uniqueID: 122FFB4E-C95E-77C1-D217186D857F2228
 
csPageID: 2011,3010,1660,3710  
 
csPageID: 2011,3010,1660,3710  
 +
</source>
  
 +
<source lang="cfm">
 
From the example data above, this will only return Record 1
 
From the example data above, this will only return Record 1
 
<cfscript>
 
<cfscript>
Line 134: Line 136:
 
                       customElementFieldName="csPageID",
 
                       customElementFieldName="csPageID",
 
                       item='4808',
 
                       item='4808',
                       'compareInList'
+
                       queryType='searchInList'
 
                       );
 
                       );
 
</cfscript>
 
</cfscript>
Line 145: Line 147:
 
</source>
 
</source>
  
Example 3b: Use getCEData(queryType='compareInList') to get the records that match each value in list with the values in a list stored in a specific custom element field:  
+
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:
 +
 
 +
<source lang="cfm">
 +
A example of two records stored a 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
 +
</source>
 +
 
 
<source lang="cfm">
 
<source lang="cfm">
 +
From the example data above, this will return Record 1 and Record 3
 
<cfscript>
 
<cfscript>
     // get data from the "My Element" custom element by a uniqueID value
+
     // get data from the "My Element" custom element  
 
     data = application.ADF.ceData.getCEData(
 
     data = application.ADF.ceData.getCEData(
 
                       customElementName="My Element",
 
                       customElementName="My Element",
 
                       customElementFieldName="csPageIDs",
 
                       customElementFieldName="csPageIDs",
                       item='2011,3010,4808,1660',
+
                       item='3780,4808',
                       'compareInList'
+
                       queryType='searchInList'
 
                       );
 
                       );
 
</cfscript>
 
</cfscript>
Line 159: Line 176:
 
<!---// loop over results (will only be records that matched the criteria)  --->
 
<!---// loop over results (will only be records that matched the criteria)  --->
 
<cfloop from="1" to="#arrayLen(data)#" index="itm">
 
<cfloop from="1" to="#arrayLen(data)#" index="itm">
     <!---// renders data from the uniqueID and Title fields from the element --->
+
     <!---// renders data from the uniqueID --->
     <cfoutput>#data[itm].values.uniqueID# #data[itm].values.Title#</cfoutput>
+
     <cfoutput>#data[itm].values.uniqueID#</cfoutput>
 
</cfloop>
 
</cfloop>
 
</source>
 
</source>

Revision as of 15:56, 17 September 2010

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 a 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 two records stored a 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>