Difference between revisions of "CEData 1 0-getCEData"
Gcronkright (talk | contribs) (→Usage:) |
|||
(50 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
+ | __NOTOC__ | ||
+ | Attention: Do not change any text in the description, signature, and paramter sections. | ||
+ | |||
+ | Return to [[CEData_1_0]] | ||
+ | |||
== Description == | == Description == | ||
Returns array of structs for all data matching the Custom Element. | Returns array of structs for all data matching the Custom Element. | ||
− | == Signature == | + | == Signature == |
+ | public array <strong>getCEData</strong> ( string customElementName, string customElementFieldName, any item, string queryType, string searchValues, string searchFields ) | ||
+ | |||
+ | == Parameters == | ||
+ | |||
+ | <table id="lib-params"> | ||
+ | <tr class="header"> | ||
+ | <td>Required</td> | ||
+ | <td>Name</td> | ||
+ | <td>Type</td> | ||
+ | <td>Description</td> | ||
+ | </tr> | ||
+ | |||
+ | |||
+ | <tr> | ||
+ | |||
+ | <td class="required">required</td> | ||
+ | |||
+ | <td>customElementName</td> | ||
+ | <td>string</td> | ||
+ | <td></td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | |||
+ | <td class="required">optional</td> | ||
+ | |||
+ | <td>customElementFieldName</td> | ||
+ | <td>string</td> | ||
+ | <td>[Default: ] </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | |||
+ | <td> </td> | ||
+ | |||
+ | <td>item</td> | ||
+ | <td>any</td> | ||
+ | <td>[Default: ] </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | |||
+ | <td> </td> | ||
+ | |||
+ | <td>queryType</td> | ||
+ | <td>string</td> | ||
+ | <td>[Default: selected] </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | |||
+ | <td> </td> | ||
+ | |||
+ | <td>searchValues</td> | ||
+ | <td>string</td> | ||
+ | <td>[Default: ] </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | |||
+ | <td> </td> | ||
+ | |||
+ | <td>searchFields</td> | ||
+ | <td>string</td> | ||
+ | <td>[Default: ] </td> | ||
+ | </tr> | ||
+ | |||
+ | </table> | ||
+ | |||
+ | == 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 <!-- (new as of 9/17/2010) --> | ||
+ | |||
+ | === 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> |
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>