![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi -- I've been learning a lot of new concepts and strategies lately thanks to all the great pointers here on this newsgroup. One of them is on p. 19 of the 'Whitepaper for FMP Novices", where the author suggests *not* allowing data entry within portals but rather a simple strategy for creating a sort of platform with fields for data entry via a new relationship based on a global field: "How then are you supposed to create portal records? Simple. Create an additional relationship to the table in question. Make it a one-to-one relationship using a global field as the primary key and the existing ID of the related record as the foreign key. Put fields from that relationship on a platform on the layout, along with a New Record button. Attach this button to a script that creates a new record in the related table, grabs the ID number of the new record and inserts it into the new global primary key field."* My question (which is probably cringingly basic) is how you "grab" the ID number and insert it into the global key field *without* using the "copy/paste" approach, which I've learned is undesireable since it clears the computer's clipboard -- and requires the fields to be on the layout. I assume it's some use of "Set Field" -- but I can't figure out how to specify the field data I want the target field set to! Thanks again albert *An additional question -- in scripting the New Record button, wouldn't you also need to add a step that enters the primary keyfield of the Parent record into the foreign keyfield of the new record, since you aren't creating the record through a portal? I'd think so... |
#3
| |||
| |||
|
|
Hi -- I've been learning a lot of new concepts and strategies lately thanks to all the great pointers here on this newsgroup. One of them is on p. 19 of the 'Whitepaper for FMP Novices", where the author suggests *not* allowing data entry within portals but rather a simple strategy for creating a sort of platform with fields for data entry via a new relationship based on a global field: "How then are you supposed to create portal records? Simple. Create an additional relationship to the table in question. Make it a one-to-one relationship using a global field as the primary key and the existing ID of the related record as the foreign key. Put fields from that relationship on a platform on the layout, along with a New Record button. Attach this button to a script that creates a new record in the related table, grabs the ID number of the new record and inserts it into the new global primary key field."* My question (which is probably cringingly basic) is how you "grab" the ID number and insert it into the global key field *without* using the "copy/paste" approach, which I've learned is undesireable since it clears the computer's clipboard -- and requires the fields to be on the layout. I assume it's some use of "Set Field" -- but I can't figure out how to specify the field data I want the target field set to! Thanks again albert *An additional question -- in scripting the New Record button, wouldn't you also need to add a step that enters the primary keyfield of the Parent record into the foreign keyfield of the new record, since you aren't creating the record through a portal? I'd think so... |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Actually, I'm maybe getting in over my head, as I'm finding the replies a little opaque. But maybe I should describe a little more clearly what I've got. I'm using FMP 8.5, and designing a simple single-user database for cataloguing collections of films. I have a series of one-to-many table relationships breaking down thus: Donations >> Collections >> Films At present, I have a portal in the Donations layout allowing creation of Collections records (a donor may bestow several distinct collections), and likewise a portal on the Donations layout allowing creation of film records (each collection is made up of many films). So starting in the Donation table I have ID_Donation_pk = ID_Donation_fk in the Collection table ID_Collection_pk = ID_Collection_fk in the Film table. Trying to avoid using the portal for data entry, I've created a global field in the Donation table IDg_CollectionEntry_pk and linked it in a 1-to-1 relationship to ID_Collection_pk in the Collections table. Over the fields in the portal displaying Collections information, I've placed a button which goes to the related record in Collection, copies the ID_Collection_pk, goes back to the Donations layout and pastes it into that new global field, so that the Collection fields that I've placed on the layout using the global relationship appears in a 'data entry' area of the layout. Then I've got a button for 'New Collection' that runs a similar script, going to the Collections table, creating a New Record, entering the ID_Donation_p and bringing back the ID_Collection_pk to the Donations global field -- again using the Cut-and-Paste method, which I understand to be undesireable. It basically works - though a few cosmetic features need attention -- (the new record appears in the portal list at the top rather than bottom, and I'd like to make a portal row be grey when its field data is being displayed in the dat entry) -- but I have a feeling it's inelegant. Again, it may be that I'm just over-reaching with the degree of knowledge I have, and I don't want to seem like I'm asking you guys to tutor me. I'm reading a lot of texts and trying to tap into some useful videos at the ISO site, but I'm finding it hard to locate the relevant lessons. Albert |
#6
| |||
| |||
|
|
There's different ways of creating new related records. .... In the second script, you're basically creating the record and then doing the same thing the Edit script is doing. To eliminate the Cut n Paste (which I strongly recommend), all you need to do is after the "New Record" script step, again just add: Set Field[Donations::IDg_CollectionEntry_pk;Collections::ID_ Collection_pk ] |
#7
| |||
| |||
|
|
In article <1183587891.611368.92... (AT) n2g2000hse (DOT) googlegroups.com>, Grip <g... (AT) cybermesa (DOT) com> wrote: There's different ways of creating new related records. .... In the second script, you're basically creating the record and then doing the same thing the Edit script is doing. To eliminate the Cut n Paste (which I strongly recommend), all you need to do is after the "New Record" script step, again just add: Set Field[Donations::IDg_CollectionEntry_pk;Collections::ID_ Collection_pk ] Thanks very much for the coaching here. The simple fix for the 'edit record' script works fine, but I'm still confused about how the 'New Record' process is supposed to work. I think I am muddled about how scripts work through 'relationships' and/or 'portals.' My 'New Record' button is in the Donations layout, so the first step in the script has to be 'Go To Collections Layout' -- otherwise I get a new *Donation* record. Right? (I don't see any options in Scriptmaker for the "New Record" script line -- it just makes a new record in the current table/layout). So I'm not seeing how, when I do this, I'm getting the appropriate Parent/Child relationship between the Donation record and the new Collection record. When the new Collection record is made, the foreign key linking it to the Donation record (which would *make* it a child) remains blank. From your responses, I get the feeling, it should be filling in this key field automatically (via the relationship), but I don't see how. Given that I'm "in" Donations, how do I script the New Record step to create a record related to the active Donation record? I guess my blind spot is that the only way I've learned to create 'child' records between related tables is through a portal, which enters the appropriate keyfield for you. Now that I'm not using the portal, I'm not seeing what's taking its place. I have both of the relationships between the tables set to 'allow' creation of records in the child table. Is that okay? Do all these key fields for the two tables involved need to appear on the layouts? I'd think no, but want to make sure. Sorry if this is really basic -I'm feeling pretty stupid. Albert |
#8
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |