dmontano Posted June 4, 2010 Posted June 4, 2010 I would like to add a particular "meta-data" field to each table in my solution. I want this field to calculate and display the table name. I read a little on the functions "TableNames" and "TableIDs" but from what I understand they will return a list of ALL table names or ALL table IDs used in the file. Since there is no "Get ( TableName )" function that I can see, how does one go about using either "TableNames" or "TableIDs" to return just the table name I am trying to get? I would like to do the same with Layout names as well - so if there is a solution - I imagine the same logic would apply. Much appreciated if you can help.
comment Posted June 4, 2010 Posted June 4, 2010 there is no "Get ( TableName )" function that I can see Have a look at the Get(LayoutTableName) function. Note that "table" here actually means "table occurrence". I would like to do the same with Layout names as well See Get(LayoutName).
dmontano Posted June 4, 2010 Author Posted June 4, 2010 Thanks Comment for the reply. Well, as usual, things are more complicated than I hoped for. The problems: I want each table to have one field that contains its table name. If I use "Get ( LayoutTableName )" it gives me the Table Occurrence Name - which can be different than the table name. I can hard code - but I want something dynamic / automatic. Ironically, I would also like to use the "Get ( LayoutTableName )" to display the TO that portals are coming from - but that doesn't work because they are coming from TOs other than the layout the TOs are based on. In short, I am trying to automate - and document - the solution. Also, facilitate the display of table names, TO names, layout names, etc. I want to prevent hard coding as much as possible. I recall some time ago wanting to use layout names in parameters but they had to be hard coded instead of referencing a field. SInce one table can feed many TOs and many layouts - I understand why it is not easy. I imagine there has to be some parsing of a list to pin-point where and what something is. Is there any way to capture the actual table name (not the TO) via a calculation? Thanks in advance!
comment Posted June 4, 2010 Posted June 4, 2010 Is there any way to capture the actual table name (not the TO) via a calculation? Not that I know of. IMHO, you're just creating extra work for yourself. For example, a portal already shows the source TO when you enter Layout mode.
dmontano Posted June 4, 2010 Author Posted June 4, 2010 Remember Comment - I am obssessive-compulsive. I am using it for display purposes - not developer purposes. I do this with layout names and it saves me work - and I do not have to worry that a layout name has changed - but the display title for the layout has not changed. I have found several uses for this type of "convention" that serves me well. I would like to do this for fields as well. Thanks for the help again.
Newbies datacreator Posted August 10, 2012 Newbies Posted August 10, 2012 Let ( [ x = GetFieldName (Self) ; count = Length (x) ; remove = 9 ; // This number should be the length of your fieldname plus 2. Mine field is "table_C" so the value is 9. ("::table_C") return = Left ( x ; ( count - remove ) ) ] ; return )
lazarus Posted August 10, 2012 Posted August 10, 2012 Try this custom function (I also uploaded it to the Brian Dunning Filemaker Pro Custom function website) // SYNTAX: ListBaseTableName // ORIGIN: http://www.decisiongroup.net // NOTES: Returns the base table name based on the table occurance on a particular layout in the current FileMaker Pro v12 file // VERSION: 1.0v1 - for FileMaker Pro v12 // © 2012 Lazarus Sismanis, Decision Group Inc., Eagleville, PA, USA // requires FileMaker Pro v12 or higher //Thanks to Andrew Duncan, Databuzz, Sydney, Australia for his ListBaseTables function ExecuteSQL ( "SELECT DISTINCT BaseTableName FROM FileMaker_Tables WHERE TableName='" & TableOccurrenceName & "'" ; "" ; "" )
Lee Smith Posted August 10, 2012 Posted August 10, 2012 It's easier to find if you use the URL for the CF ListBaseTableName
dansmith65 Posted August 10, 2012 Posted August 10, 2012 To get the CF posted by lazarus to work, you will need to use this in the calculation definition for the field: (this calculation hasn't been tested, but I think it will work) ListBaseTableName( GetValue( Substitute( GetFieldName( self ) ; "::" ; ¶ ) ; 1 ) ) ...but that's only going to work in FM12. Of course, you could use an SQL plug-in to make that Custom Function work in versions prior to 12.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now