![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, I defined a relational FMPro db with two tables one for the company address and the second one for company products. I use a company ID key to join the two tables. I designed 2 layouts one for company address and another one for products. In my company address, I would like to have a button to create a new product record, the script should switch to the product layout then edit the company ID field and set the appropriate value for it (th e company ID from the company address layout). With this matter, I don't to report manually the "foreign" key in the product record. My problem is I do not know how to get the value of the company ID key, I tested script like that but it did not work : Go to Layout [ "product" (products) ] New Record/Request Go to Field [ product::Company_ID ] Set Field [ product::Company_ID; GetField ( company::Company_ID ) ] # Thanks for reading and for your help Tof |
#3
| |||
| |||
|
|
nufin <NUFIN@CZ> wrote: Hello, I defined a relational FMPro db with two tables one for the company address and the second one for company products. I use a company ID key to join the two tables. I designed 2 layouts one for company address and another one for products. In my company address, I would like to have a button to create a new product record, the script should switch to the product layout then edit the company ID field and set the appropriate value for it (th e company ID from the company address layout). With this matter, I don't to report manually the "foreign" key in the product record. My problem is I do not know how to get the value of the company ID key, I tested script like that but it did not work : Go to Layout [ "product" (products) ] New Record/Request Go to Field [ product::Company_ID ] Set Field [ product::Company_ID; GetField ( company::Company_ID ) ] # Thanks for reading and for your help Tof You're doing it the hard way. Put a portal on the company address layout, using the relatonship to the company products table occurance. Make sure the relationship definition is set to allow creation of records. Put fields in the first portal row, also from the company products relationship, such as Part No, Description, & Price. All the same fields you want to fill out in the Product detail screen. Now, when you type in the last portal row, the one with the blank fields showing, a child record is created WITH the connecting ID data already in place. The script above won't work because when you switch layouts, you lose the context of the former screen, so the script doesn't know WHAT Company ID to use. To really transfer data that way, use a global field, either in one of the two tables or in a separate table of globals. First Set the global field with the current COmpany ID, then switch layouts, then create the new record and set the Company ID field from the value in the global. But I'd try the portal first, to see if that fits your needs. Sometimes it's better not to switch layouts on users, makes their experience more seamless. Lynn Allen -- Allen & Allen Semiotics www.semiotics.com FSA Associate Filemaker Design & Consulting |
![]() |
| Thread Tools | |
| Display Modes | |
| |