Product Logo

CNS Query

Query your databases without relationships.

Functions

CNSQuery_AddField

NameCNSQuery_AddField
Description

This function Adds a new Field to an existing Table. The first parameter is the Name of a Table Occurrence of the Table to Add the new Field to. If you do not specify this parameter, CNS Query will use Get(LayoutTableName) to get the current Table and Add the Field to that Table. The second parameter is the name for the new Field. The third parameter is the Type of Field to Add and can be any one of the following values: “Text”, “Number”, “Date”, “Time”, “Timestamp”, or “Container”. If you do not specify the Field Type, CNS Query will create a “Text” Field. If you are using FileMaker Pro 8.5 or above, you can use the fourth parameter to specify if the new Field should be a Global Field. By default, CNS Query will check to make sure the Table Name you specify exists before attempting to Add the new Field. If you already know for sure that the Table exists, you can pass True as the fifth parameter.

Note: In FileMaker Pro 8.5 and above, you must insert a “Pause” Script Step after using this function in order for the new Field to be Added.

Return TypeText
FormatCNSQuery_AddField ( TOName ; FieldName ; FieldType ; AsGlobal ; SkipTONameCheck )
Required Parameters
TOName

The Name of a Table Occurrence for the Table to receive the new Field. Specify “” to use the Current Layout TO. In FileMaker Pro 11 and above, you can optionally specify the Database FileName (without the “.fp7” extension) containing the TO in the format “FileName.TOName”.

FieldName

The Name of the new Field.

Optional Parameters
FieldType

The Type of Field to Add. Specify “Text”, “Number”, “Date”, “Time”, “Timestamp”, or “Container”. CNS Query uses “Text” as the default.

AsGlobal

If True, the plug-in will Add a Field with Global storage instead of a normal Field. This parameter is only available in FileMaker Pro 8.5 and above.

SkipTONameCheck

If True, the plug-in will not check to make sure the TO Name you specified actually exists before attempting to Add the Field.

Examples
Example 1

Adds a new Text Field named "MyField" to the "MyTable" Table.

CNSQuery_AddField( "MyTable" ; "MyField" )
Example 2

Adds a new Global Number Field named "gNum" to the current Table. (This would only work on FileMaker Pro 8.5 and above.)

CNSQuery_AddField( "" ; "gNum" ; "Number" ; True )
Example 3

In FileMaker Pro 11 and above, use this form to add a field to a Table Occurrence in a separate, open Database file.

CNSQuery_AddField( "AnotherFile.MyTable" ; "MyField" )