Difference between revisions of "CEData 1 0-getCEData"

From ADF Docs
Jump to: navigation, search
(Usage:)
(Usage:)
 
(11 intermediate revisions by 3 users not shown)
Line 94: Line 94:
  
 
=== Usage: ===
 
=== Usage: ===
Example 1: Use getCEData to return ALL records in a Custom Element:  
+
Example 1: Use getCEData(queryType='selected') to return ALL records in a Custom Element:  
<source lang="cfm">
+
 
<cfscript>
+
<cfscript>
 
     // get data from the "My Element" custom element  
 
     // get data from the "My Element" custom element  
 
     data = application.ADF.ceData.getCEData(
 
     data = application.ADF.ceData.getCEData(
 
                       customElementName="My Element"
 
                       customElementName="My Element"
 
                       );
 
                       );
</cfscript>
+
</cfscript>
 +
 +
&lt;!---// loop over results (All the records from the Custom Element) ---&gt;
 +
<cfloop from="1" to="#arrayLen(data)#" index="itm">
 +
    &lt;!---// renders data from the uniqueID and Title fields from the element ---&gt;
 +
    <cfoutput>#data[itm].values.uniqueID# #data[itm].values.Title#</cfoutput>
 +
</cfloop>
  
<!---// loop over results (All the 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>
 
</source>
 
  
 
Example 2: Use getCEData(queryType='selected') to return only the records that match the provided value for a specific field:  
 
Example 2: Use getCEData(queryType='selected') to return only the records that match the provided value for a specific field:  
<source lang="cfm">
+
 
<cfscript>
+
<cfscript>
 
     // get data from the "My Element" custom element by a uniqueID value
 
     // get data from the "My Element" custom element by a uniqueID value
 
     data = application.ADF.ceData.getCEData(
 
     data = application.ADF.ceData.getCEData(
Line 119: Line 119:
 
                       item='DF6D9B32-1143-FF53-952805B368AB301B'
 
                       item='DF6D9B32-1143-FF53-952805B368AB301B'
 
                       );
 
                       );
</cfscript>
+
</cfscript>
 +
 +
&lt;!---// loop over results (Only the records that matched the criteria)  ---&gt;
 +
<cfloop from="1" to="#arrayLen(data)#" index="itm">
 +
    &lt;!---// renders data from the uniqueID and Title fields from the element ---&gt;
 +
    <cfoutput>#data[itm].values.uniqueID# #data[itm].values.Title#</cfoutput>
 +
</cfloop>
  
<!---// loop over results (Only the 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>
 
</source>
 
  
 
Example 3: Use getCEData(queryType='selected') to return only the records that match a comma-delimited list of provided values for a specific field (similar to a SQL 'IN' operator):
 
Example 3: Use getCEData(queryType='selected') to return only the records that match a comma-delimited list of provided values for a specific field (similar to a SQL 'IN' operator):
<source lang="cfm">
+
 
A example of three records stored in the "My Element" custom element:  
+
A example of three records stored in the "My Element" custom element:  
Record 1:
+
Record 1:
 
   uniqueID: DF6D9B32-1143-FF53-952805B368AB301B
 
   uniqueID: DF6D9B32-1143-FF53-952805B368AB301B
 
   Title: 'Record 1'  
 
   Title: 'Record 1'  
Record 2:
+
Record 2:
 
   uniqueID: 122FFB4E-C95E-77C1-D217186D857F2228
 
   uniqueID: 122FFB4E-C95E-77C1-D217186D857F2228
 
   Title: 'Record 2'  
 
   Title: 'Record 2'  
Record 3:
+
Record 3:
 
   uniqueID: 1BC95CDE-DFBC-047C-2011FC37BE5F6A22
 
   uniqueID: 1BC95CDE-DFBC-047C-2011FC37BE5F6A22
 
   Title: 'Record 3'  
 
   Title: 'Record 3'  
</source>
+
 
 
+
From the example 3 data above, this will return Record 1 and Record 2
<source lang="cfm">
+
<cfscript>
From the example 3 data above, this will return Record 1 and Record 2
 
<cfscript>
 
 
     // get data from the "My Element" custom element by a uniqueID value
 
     // get data from the "My Element" custom element by a uniqueID value
 
     data = application.ADF.ceData.getCEData(
 
     data = application.ADF.ceData.getCEData(
Line 152: Line 150:
 
                       queryType="selected"
 
                       queryType="selected"
 
                       );
 
                       );
</cfscript>
+
</cfscript>
</source>
+
 
  
 
Example 4: Use getCEData(queryType='notselected') to return only the records that '''DO NOT''' match a comma-delimited list of provided values for a specific field (similar to a SQL 'NOT IN' operator):
 
Example 4: Use getCEData(queryType='notselected') to return only the records that '''DO NOT''' match a comma-delimited list of provided values for a specific field (similar to a SQL 'NOT IN' operator):
  
<source lang="cfm">
+
From the example 3 data above, this will return Record 3
From the example 3 data above, this will return Record 3
+
<cfscript>
<cfscript>
 
 
     // get data from the "My Element" custom element by a uniqueID value
 
     // get data from the "My Element" custom element by a uniqueID value
 
     data = application.ADF.ceData.getCEData(
 
     data = application.ADF.ceData.getCEData(
Line 167: Line 164:
 
                       queryType="notselected"
 
                       queryType="notselected"
 
                       );
 
                       );
</cfscript>
+
</cfscript>
</source>
+
 
  
 
Example 5: 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:
 
Example 5: 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">
+
A example of two records stored in the "My Element" custom element:
A example of two records stored in the "My Element" custom element:
+
Record 1:
Record 1:
 
 
   uniqueID: DF6D9B32-1143-FF53-952805B368AB301B
 
   uniqueID: DF6D9B32-1143-FF53-952805B368AB301B
 
   csPageIDList: 2011,3010,4808,1660,3710
 
   csPageIDList: 2011,3010,4808,1660,3710
Record 2:
+
Record 2:
 
   uniqueID: 122FFB4E-C95E-77C1-D217186D857F2228
 
   uniqueID: 122FFB4E-C95E-77C1-D217186D857F2228
 
   csPageIDList: 2011,3010,1660,3710
 
   csPageIDList: 2011,3010,1660,3710
Record 3:
+
Record 3:
 
   uniqueID: 1BC95CDE-DFBC-047C-2011FC37BE5F6A22
 
   uniqueID: 1BC95CDE-DFBC-047C-2011FC37BE5F6A22
 
   csPageIDList: 2011,3010,3780,1660,9884
 
   csPageIDList: 2011,3010,3780,1660,9884
</source>
 
  
<source lang="cfm">
+
From the example 5 data above, this will only return Record 1
From the example 5 data above, this will only return Record 1
+
<cfscript>
<cfscript>
 
 
     // get data from the "My Element" custom element  
 
     // get data from the "My Element" custom element  
 
     data = application.ADF.ceData.getCEData(
 
     data = application.ADF.ceData.getCEData(
Line 195: Line 189:
 
                       queryType='searchInList'
 
                       queryType='searchInList'
 
                       );
 
                       );
</cfscript>
+
</cfscript>
</source>
+
 
  
 
Example 6: 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:  
 
Example 6: 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">
+
From the example 5 data above, this will return Record 1 and Record 3
From the example 5 data above, this will return Record 1 and Record 3
+
<cfscript>
<cfscript>
 
 
     // get data from the "My Element" custom element  
 
     // get data from the "My Element" custom element  
 
     data = application.ADF.ceData.getCEData(
 
     data = application.ADF.ceData.getCEData(
Line 210: Line 203:
 
                       queryType='searchInList'
 
                       queryType='searchInList'
 
                       );
 
                       );
</cfscript>
+
</cfscript>
</source>
+
 
 +
 
 +
Example 7: Use getCEData(queryType='search') to return the records that match at least part of the value of the CE field specified in the 'searchFields' attribute. Specifying querytype of "search" is only for finding records with a specific value in the field, whereas "searchInList" is for finding one or more values in the field. 
 +
 
 +
From the example 5 data above, this will return Record 1
 +
<cfscript>
 +
    // get data from the "My Element" custom element
 +
    data = application.ADF.ceData.getCEData(
 +
                      customElementName="My Element",
 +
                      searchFields="uniqueID",
 +
                      searchValues='DF6D9B32',
 +
                      queryType='search'
 +
                      );
 +
</cfscript>
 +
 
 +
 
 +
Example 8: Use getCEData(queryType='multi') to return the records that match multiple fields in the CE record.  The 'searchFields' argument will contain the list of CE fields to search and the 'searchValues' argument is a one-to-one match for the 'searchFields' list.  In the example below, the filter criteria is interpreted as 'department=Science AND building=Adams Hall".
 +
 
 +
A example of three records stored in the "My Element" custom element:
 +
Record 1:
 +
  uniqueID: DF6D9B32-1143-FF53-952805B368AB301B
 +
  Title: 'Record 1'
 +
  Department: Science
 +
  Building: Adams Hall
 +
Record 2:
 +
  uniqueID: 122FFB4E-C95E-77C1-D217186D857F2228
 +
  Title: 'Record 2'
 +
  Department: Math
 +
  Building: Washington Hall
 +
Record 3:
 +
  uniqueID: 1BC95CDE-DFBC-047C-2011FC37BE5F6A22
 +
  Title: 'Record 3'
 +
  Department: Science
 +
  Building: Adams Hall
 +
 
 +
From the example 8 data above, this will return Record 1 and Record 3
 +
<cfscript>
 +
    // get data from the "My Element" custom element by a uniqueID value
 +
    data = application.ADF.ceData.getCEData(
 +
                      customElementName="My Element",
 +
                      searchFields="Department, Building",
 +
                      searchValues='Science, Adams Hall',
 +
                      queryType="multi"
 +
                      );
 +
</cfscript>

Latest revision as of 19:40, 7 July 2015

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.

queryType options:

  • selected
  • notSelected
  • search
  • multi
  • versions
  • list
  • numericList
  • greaterThan
  • between
  • searchInList

Usage:

Example 1: Use getCEData(queryType='selected') 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 (All the 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(queryType='selected') 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 (Only the 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 3: Use getCEData(queryType='selected') to return only the records that match a comma-delimited list of provided values for a specific field (similar to a SQL 'IN' operator):

A example of three records stored in the "My Element" custom element: 
Record 1:
 uniqueID: DF6D9B32-1143-FF53-952805B368AB301B
 Title: 'Record 1' 
Record 2:
  uniqueID: 122FFB4E-C95E-77C1-D217186D857F2228
  Title: 'Record 2' 
Record 3:
 uniqueID: 1BC95CDE-DFBC-047C-2011FC37BE5F6A22
 Title: 'Record 3' 
From the example 3 data above, this will return Record 1 and Record 2
<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,122FFB4E-C95E-77C1-D217186D857F2228',
                      queryType="selected"
                     );
</cfscript>


Example 4: Use getCEData(queryType='notselected') to return only the records that DO NOT match a comma-delimited list of provided values for a specific field (similar to a SQL 'NOT IN' operator):

From the example 3 data above, this will return Record 3
<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,122FFB4E-C95E-77C1-D217186D857F2228',
                      queryType="notselected"
                     );
</cfscript>


Example 5: 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
 csPageIDList: 2011,3010,4808,1660,3710
Record 2:
 uniqueID: 122FFB4E-C95E-77C1-D217186D857F2228
 csPageIDList: 2011,3010,1660,3710
Record 3:
 uniqueID: 1BC95CDE-DFBC-047C-2011FC37BE5F6A22
 csPageIDList: 2011,3010,3780,1660,9884
From the example 5 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="csPageIDList",
                      item='4808',
                      queryType='searchInList'
                     );
</cfscript>


Example 6: 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:

From the example 5 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="csPageIDList",
                      item='3780,4808',
                      queryType='searchInList'
                     );
</cfscript>


Example 7: Use getCEData(queryType='search') to return the records that match at least part of the value of the CE field specified in the 'searchFields' attribute. Specifying querytype of "search" is only for finding records with a specific value in the field, whereas "searchInList" is for finding one or more values in the field.

From the example 5 data above, this will return Record 1
<cfscript>
    // get data from the "My Element" custom element 
    data = application.ADF.ceData.getCEData(
                      customElementName="My Element",
                      searchFields="uniqueID",
                      searchValues='DF6D9B32', 
                      queryType='search'
                     );
</cfscript>


Example 8: Use getCEData(queryType='multi') to return the records that match multiple fields in the CE record. The 'searchFields' argument will contain the list of CE fields to search and the 'searchValues' argument is a one-to-one match for the 'searchFields' list. In the example below, the filter criteria is interpreted as 'department=Science AND building=Adams Hall".

A example of three records stored in the "My Element" custom element: 
Record 1:
 uniqueID: DF6D9B32-1143-FF53-952805B368AB301B
 Title: 'Record 1'
 Department: Science
 Building: Adams Hall
Record 2:
 uniqueID: 122FFB4E-C95E-77C1-D217186D857F2228
 Title: 'Record 2'
 Department: Math
 Building: Washington Hall
Record 3:
 uniqueID: 1BC95CDE-DFBC-047C-2011FC37BE5F6A22
 Title: 'Record 3'
 Department: Science
 Building: Adams Hall
 
From the example 8 data above, this will return Record 1 and Record 3
<cfscript>
    // get data from the "My Element" custom element by a uniqueID value
    data = application.ADF.ceData.getCEData(
                      customElementName="My Element",
                      searchFields="Department, Building",
                      searchValues='Science, Adams Hall',
                      queryType="multi"
                     );
</cfscript>