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

I need a button to conditionally switch layouts

Featured Replies

It turns out I am terrible with Filemaker, so I'm hoping someone can help. I have a database that will be used by several people and so I want to make it dummy proof. For each of two tables there is a layout, so I use "layout" to refer to both a new layout and table in this description:

On layout #1, I have a button that, if clicked, should switch to layout #2 and 1) create a new record if the ID field in layout #1 does not exist in layout #2, or 2) go to an existing record if that ID does exist. Thus, there will never be more than one record in layout #2 for each record in #1.

Hopefully this makes sense. Any help is much, much, much appreciated!

Assuming that the record is related, the script would be something like:

If [ Is Empty (Table2::ID) ]

Set Variable [ $recID; Table1::RecordID]

Go to Layout [ Layout 2 ]

New Record []

Set Field [ Table2::ID; $recID ]

Commit Record []

Else

Go to Related Record [ Show only related record; from Table: "Table2"; using layout: "Table 2" ]

End If

  • Author

Thanks very much! It is almost perfect but there is one scenario in which it doesn't work. Example:

From record #6 at main table/layout, I click the button and it takes me to layout 2, which contains a record ID field and a portal to another table. It correctly fills in the record ID field with a 6. But if I go back to the main table/layout via another button I created WITHOUT having entered data into the portal, and then click on the button you provided the script for again, it takes me to layout 2 but creates a second record with a 6 in it. This does not happen if I enter data into the portal the first time I go to layout two.

Very confusing to me.

Regardless of whether or not you provide a fix for this, I very much appreciate your help! This forum is really great for users such as myself.

After seeing this thread again and since there will only be one record, I think that if you 'Allow Creation of Record' in your relationship from Table 1 to Table 2, then you can shorten up the script to be:

If [ Is Empty (Table2::ID) ]

Set Field [ Table2::ID; $recID ]

Commit Record []

Else

Go to Related Record [ Show only related record; from Table: "Table2"; using layout: "Table 2" ]

End If

Also next time that you post something, it may be better if you use actual names rather than abstract Table 1, Table 2, while the layout naems being the same. It just adds confusion for others that might read the thread.

  • Author

That didn't work either. I imagine I have something set up in an amateurish way that is preventing full functionality. So I took a slightly different tact. For the button that takes me back to the main layout from the second one, I edited the script and had it check to see if a record was created in the portal. If it wasn't, it deletes the record before returning to the main layout. Seems to work.

Thanks again for your help!

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

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.