GETCOLUMNVALUES

Returns an array of values which satisfy the wherestring from the specified table. An application of this function is on the ShowOrdersTable page to display the total orders placed by a customer, e.g.:

= GETCOLUMNVALUES("Orders", "OrderID", "CustomerID = '" + CustomerID +"'").LENGTH

Syntax

= GETCOLUMNVALUES(tableName, fieldName)

= GETCOLUMNVALUES(tableName, fieldName, whereString)

Parameters

tableName

A string which represents the name of the table from which the value is to be fetched.  This table must be included in the application in order for GETCOLUMNVALUES to return a value.

The TableName parameter is actually table class name without suffix instead of table name.  Sometime table class name and table name are not the same.  For example, if the table name has a space such as “Order Details”, the table class name will be “Order_DetailsTable”.  Table class name without suffix is “Order_Details”.  The correct value of tableName parameter is Order_Details.  To find the correct table class name, refer to the Business Layer.

As you see, there is a file called “Order_DetailsTable”.   This is how you find the table class name.  For tables, the suffix is “Table”, For views, the suffix is “View”.  For custom queries, the suffix is “Query”.  These suffixes should not be presented on the tableName parameter.

fieldName

The name of the field whose value is to be found.

The FieldName parameter is actually a field code name.  Sometimes the field name and field code name are not the same.  For example, if the field name is called “ID”, the code name will be “ID0”.  To find the code name for the fields, first locate the base table class in the business layer.  For example, for the table name called “Users”, go to BaseUsersTable.vb(cs).  If this file is not shown on Application Explorer, please make sure your application has been built and set Application Explorer to display all files by selecting View->Display all source files.

Then look into the Initialize method, you should see code name is defined in this method.

whereString

(optional)

A string which represents the where clause to filter the contents of the table using a specific condition.

Return Type

String[]

Examples

Example

Returns

= GETCOLUMNVALUES("Employees", "City", "Country = 'USA'")

A list of all Cities in the US from the Employees table.

= GETCOLUMNVALUES(“Orders”, “OrderID”, “ShipCountry=“ + “’” + URL(“MyShipCountry”) + “’”)

All the OrderIDs for which the ShipCountry is passed as the URL value.

= STRING.JOIN(“,”, GETCOLUMNVALUES( “Employees”, “City”))

A concatenated version of all the cities in the Employees table.

= STRING.JOIN(",",GETCOLUMNVALUES( "SalesRep", "SalesRepID", "SalesRepID=" + UserId()))

This shows the joined values from all the records retrieved.