Does anyone know an easy way to script to check all of the fields on a layout to see if any are duplicates?
Plenty of information on finding duplicate records, but still searching for a simple quick check on fields...
Since "Go To Object" only handles named objects (instead of next/first/last/previous), I can't really think of a way to script this easily inside of filemaker.
Using the built in DDR (database design report) under the "tools" menu, you might be able to see if there are duplicate fields on a layout. You can constrain to only exporting the "layouts" section of the report.
There's a few solutions out there that read and process DDR files (Beezwax inspector for instance, was just overhauled and has a gorgeous UI ).
You can use the Design function "FieldNames ( Get ( FileName ) ; "my_layout" )".
This will list all the fields on the layout, including duplicates. Using variables and maybe a custom function or two you should be able to determine if there is a duplicate field name.
Set variable ($field_list ; FieldNames ( Get ( FileName ) ; "my_layout" ) )
//Sort List of field names; Custom Function or a subscript.
Set Variable ($field_list_sorted ; Sort_var_list ( $field_list ) )
//Dedup the list; Custom function or a subscript.
Set Variable ( $dup_fields ; Find_dup_var ( $field_list_sorted ) )
Since a developer must put the fields on a layout then you would know, right? However, here is one way to know IF there are duplicate fields. Script would be:
View As [ View as Form ]
Set Variable [ $kount; Value: ValueCount ( FieldNames ( Get ( FileName ) ; Get ( LayoutName ) ) ) ]
View As [ View as Table ]
If [ $kount - ValueCount ( FieldNames ( Get ( FileName ) ; Get ( LayoutName ) ) ) ]
... there is a duplicate field ... do whatever you wish or just display custom dialog
Reason being that form view shows all fields including duplicates but table view only sees one of each field. If you wish to know exactly which fields are duplicates, we'll have to compare the two lists.
To list the duplicate fields, you can use a CF such as Ray Cologon's ZapValues which is:
IsEmpty ( ListA ) ; "" ;
LeftValues ( ListA ; IsEmpty ( FilterValues ( LeftValues ( ListA ; 1 ) ; ListB ) ) ) &
ZapValues( RightValues ( ListA ; ValueCount ( ListA ) - 1 ) ; ListB )
... ListA would be FieldNames ( Get ( FileName ) ; Get ( LayoutName ) ) while in form view and ListB would be the 'lesser' list while in table view.
The DDR will also give you the exact position of the fields on the layout, so you can easily find them.
LaRetta ha scritto: View As [ View as Form ]...View As [ View as Table ]
LaRetta ha scritto:
View As [ View as Form ]
Very clever !
BTW: it is simpler to use a single custom function like in the attached example.
Retrieving data ...