Newbies Martin The Posted September 9, 2006 Newbies Share Posted September 9, 2006 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 Link to comment Share on other sites More sharing options...
Søren Dyhr Posted September 9, 2006 Share Posted September 9, 2006 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 Link to comment Share on other sites More sharing options...
Newbies Martin The Posted September 9, 2006 Author Newbies Share Posted September 9, 2006 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 Link to comment Share on other sites More sharing options...
Søren Dyhr Posted September 13, 2006 Share Posted September 13, 2006 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 Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 6570 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 accountSign in
Already have an account? Sign in here.
Sign In Now