Product Logo

CNS Query

Query your databases without relationships.

Functions

CNSQuery_GetFieldIDs

NameCNSQuery_GetFieldIDs
Description

This function returns either the ID of a specific Field or a list of “FieldName=FieldID” pairs for all Fields in a Table. The first parameter is the Name of a Table Occurrence of the Table to return the Field IDs from. If you do not specify this parameter, CNS Query will use Get(LayoutTableName) to get the current Table to return the Field IDs from. If you specify a Field Name in the second parameter, CNS Query will return the Field ID of that specific Field. If you do not specify this parameter, CNS Query will return a list of “FieldName=FieldID” pairs for all the Fields in the Table. By default, CNS Query will check to make sure the TO Name and the Field Name you specify exist before getting the Field IDs. If you already know for sure that the TO Name and the Field Name exist, you can pass True as the third and fourth parameters.

Note: In FileMaker Pro 7 through 10, to ensure that you get the Field IDs of all the Fields in your Table, you must make sure that there is not a Layout in your Database with the same name as the TO Name you specify for this function. In FileMaker Pro 11 and above, this is not an issue.

Return TypeText or Number
FormatCNSQuery_GetFieldIDs ( TOName ; FieldName ; SkipTONameCheck ; SkipFieldNameCheck )
Optional Parameters
TOName

The Name of a Table Occurrence of the Table that contains the Fields. 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

If you specify this parameter, CNS Query will return the ID of the Field you specify. Otherwise, CNS Query will return all the IDs of all the Fields.

SkipTONameCheck

If True, CNS Query will not check to make sure the TO Name you specify actually exists.

SkipFieldNameCheck

If True, CNS Query will not check to make sure the Field Name you specify actually exists.

Examples
Example 1

Returns something like:<br/> AField=1<br/> BField=2

CNSQuery_GetFieldIDs( "MyTable" )
Example 2

Returns 2 if the Field ID for the "BField" Field in the current Table is 2.

CNSQuery_GetFieldIDs( "" ; "BField" )
Example 3

In FileMaker Pro 11 and above, use this form to get the Field IDs of a Table in a separate, open Database file.

CNSQuery_GetFieldIDs( "AnotherFile.MyTable" )