September 9, 200619 yr 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
September 9, 200619 yr 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
September 9, 200619 yr 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
September 13, 200619 yr 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