Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

  • Newbies
Posted

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

Posted

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

  • Newbies
Posted

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

Posted

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

This topic is 6704 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.