Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

GetFieldTableName Problem

Featured Replies

I am trying to set up an AuditLog system. In the interest of experimentation I have tried to implement this in a db that has the data file and the interface file separated. The idea is that log will contain modifications from all tables in the data file so you need to capture the name of the table as well as the name of the field that has been modified. The Custom Function is in the data file. It is triggered when one of the defined fields in the data table is modified. The code in the function is:

Let([

$$RecID= Get (RecordID);

$$Fnm = Get(ActiveFieldName);

$$TableName = Get(ActiveFieldTableName);

$$Fval = GetField($$Fnm);

$$Nval = If(Length($$Fval); $$Fval; "[null]")];

If(Length($$Fnm); LogField+1; LogField)

I then run a script in the data file that creates a new record in the Log table and populates the fields with the variables.

The problem that I am having is the $$TableName = Get(ActiveFieldTableName) part does not return the correct value, it returns log instead of the table name of the modifed field. The strange thing is that the Get(ActiveFieldName) part works correctly as does getting the value from the Active Field Name. It works perfectly if you go to the data file and modify a field but fails when the field is modified via the interface file.

Is this a bug with Get(ActiveFieldTableName)?? or am I missing something? Is there another way of capturing the name of the table that a field belongs too?

Any advice would be very welcome.

Thanks

Hi Danny

I'm not sure if this is a bug, at first glance it seems it is, but this is an issue of context when the calculation is evaluated. FileMaker help states -

"If the current calculation is stored and you specify its context, this function will be evaluated based on that context; otherwise, it will be evaluated based on the context of the current window."

Now Get ( ActiveFieldName ) actually works as you'd expect, but Get ( ActiveFieldTableName ) seems to be getting the table of the context in Log. Is this calculation being evaluated at any point later in the script?

E.g.

Set Field [ TheField ; $$FNM ]

...

Set Field [ TheTable ; $$TableName ]

If the calculation was re-evaluated at any point between these 2 steps then the active table would of course be Log.

Remember the $$Variables are set based on the current context every time the Custom Function is called.

  • Author

Hi Matt

good to hear from you.

I think you're right that it is a context issue but as you say it works for Get(activefieldname) it should work for get(activefieldtablename). I don't believe the function is being re-triggered, if it was I would expect the get(activefieldname) variable to change as well. Also after the function is called a script is triggered and this is not happening. Having said that I will check.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.