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.

Auto insert foreign key

Featured Replies

  • Newbies

Hi guys,

I am teaching myself FM, and I have a sticking point right now.

How do I auto insert a foreign key from another table?

Say I have a customer details with a unique ID, then I jumped from customer layout to order layout. Then I want to create a new order, clicking a the new record button, then I want that FM automatically fills in the customer ID (foreign key) with the active customer ID. How is it done? I have relationship set-up, but it does not auto fill.

Thank you in advance.

Regards,

Martin

You have apparently reasons to avoid the portal with the dangling empty box in a realtion with "allow creation..." Then could the button that make you jump to the order layout, could be stuffed this way:

If [ Length ( Clients::ClientID ) ] 

     Set Variable [ $who; Value:Clients::ClientID ] 

     Go to Layout [ “Order” (Order) ] 

     New Record/Request 

     Set Variable [ $who; Value:"" ] 

End If

Here, apply the $who to the autoenter option of the foreignkey field in the order layout/table.

--sd

  • Author
  • Newbies

Wow... Thank you!

Variables, that was the missing piece of the puzzle. I did not know that variables is supported by FMP.

My gratitude sir.

Martin

But perhaps using the script parameter to convey the value is more obvious?? If not a button'ed script call, use a recursion in the script to pick it up. The variables method first really shines when several foreign keys needs transfere!

--sd

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.