Brian Dunning's FileMaker Custom Functions

FM_Name_ID ( _Name_ID ; _TLFSV ; _fileName ; _layoutName )

Returns FileMaker item Name or ID, given the other

  Average rating: 4.1 (48 votes) Log in to vote

Fabrice Nordmann   Fabrice Nordmann
1-more-thing
https://www.1-more-thing.com

Share on Facebook Share on Twitter

  Sample input:
FM_Name_ID ( "MyLayout" ; "L" ; "" ; "" )

FM_Name_ID ( 112 ; "L" ; "" ; "" )
  Sample output:
112

"MyLayout"

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This function avoids hardcoding names (hardcoding IDs is much less trouble)
Give a filemaker element (field, layout, table or value list) name, and get its ID. Give it the ID, get the name.

 

Comments

Daniel A. Shockley   Daniel A. Shockley, New York, NY
Nov 16, 2010
Correction: There is a missing ampersand in the last line of code, between the paragraph character and _item (¶ _item )
 
Daniel A. Shockley   Daniel A. Shockley, New York, NY
Jan 27, 2011
With a few changes, this can handle fully-qualified field names (i.e. TableName::FieldName, like you get from GetFieldName). Also, it can be used to stored a (base-)TableID::FieldID to get a field name (without specifying a layout/table-name). Note also the ampersand error in the function as listed here.

MODS:

After the line:
; _t = Case ( _t = "T" ; "Table" ; _t = "L" ; "Layout" ; _t = "F" ; "Field" ; _t = "S" ; "Script" ; _t = "V" ; "ValueList" )

ADD:
; _layoutName = If( _t = "Field" and _layoutName = GetAsNumber( _layoutName ); FM_Name_ID( _layoutName; "T"; ""; "" ); _layoutName ) // allow TableID::FieldID parameter


After the line:
; _p = Case ( _t = "Field" and PatternCount ( _p ; "::" ) ; Replace ( _p ; 1 ; Position ( _p ; "::" ; 1 ; 1 ) + 1 ; "" ) ; _p ) // for fields, do not take TO

ADD:
; _p = Case ( _t = "Table" and PatternCount ( _p ; "::" ) ; Left ( _p ; Position ( _p ; "::" ; 1 ; 1 ) - 1 ) ; _p ) // for tables, do not take the field-name part, if there is one


Here are the revision comments:

v.1.5.1m2 (modification suggestion), Dec 2010 - suggestion by Daniel A. Shockley
Can now get the field name from a fully-qualified field ID ("tableID::fieldID" - e.g. "20384::43" ) - use the BASE table in the parameter.

v.1.5.1m1 (modification suggestion), Nov 2010 - suggestion by Daniel A. Shockley
Added ability to get the ID for a Table Occurrence from a fully-qualified field name ("myTable::myField") - use the BASE table in the
 
Fabrice Nordmann   Fabrice Nordmann, 1-more-thing
Jan 27, 2011
Hi, thanks for the posts.
Actually, these features are already there :
http://fmfunctions.com/fid/82

Sorry, sometimes hard to update everywhere :)
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Under construction. Email me your wish list for improvements.