Jump to content

How to "Get ( TableName )" for each table


This topic is 4271 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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.

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 years later...
  • Newbies

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 )

Link to comment
Share on other sites

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 & "'" ; "" ; ""  )

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 4271 days old. Please don't post here. Open a new topic instead.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.