Your post contradicts itself. You say that they aren't related and then you discuss relating the tables in a relationship.
There are two options. You are correct that you can set up a relationship for this. Search on this forum or search the web for the term "MagicKey". This is a special relationship that enables you to create new records via it that would do what you describe.
If you don't want to set up a relationship, You can have the user enter the data into a set of global fields (these can be located in a popover for that purpose), then your script can change layouts to a layout based on the desired table, create a new record and use set field to transfer the data from the global fields into corresponding fields of the new record. This second method is often done in a new window opened "off the edge" of the monitor if implemented in FileMaker Pro. (Can't do an "off the edge" window in FileMaker GO on an iOS device). This is done with a new window script step that specifies "large negative values" for the top and left position of the window so that the user never sees the window.
Yes, you can add records to a non-related table. Create a new window (offscreen) and insert the records there.
Or, create a relationship based on a global field that ties to the primary key (auto-enter only) of the target table. Set the global field to null and use Set Field to insert the data. The global field on the parent side will automatically update itself to match the newly created primary key.
Or, use a regular relationship (with or without a portal; depends on whether you need to create multiple records).
In none of these cases do you have to create "fake" fields. But you would need to script it.
Or, you can just use the portal to allow the user to insert the records directly. That's one of its purposes, after all.
Thanks Phil - ill check the magickey thing out. On the second option, I am trying to avoid adding a ton of global fields just for record creation if possible.
Thanks Mike -
Questions: On your option #1 - Where would the user type the data into? I understand popping a window offscreen and creating the records but they would still need to type the data in for the new record.
On the portal - the issue is that the records in this other table arent related to the current layout table at all. So when I try to add records I am getting issues.
I will try to read through your second option and this magickey out, they sound like possibly the same solution, that might work.
I’m not sure why you want to create related records that aren’t related, but you really have only two options: Either a series of global fields with scripted saves, or a portal that’s related.
What are you trying to avoid / gain by not simply creating a relationship?
Im trying to allow the user to create records from a popover without having to leave this layout and go to another layout basically. I read up on the magic key and I think it will work and I only have to add one more "fake field" if you will to my table, thats not too bad. Im going to take a stab at implementing it.
Yes, I know that. But it wasn’t the question. What do you think you’re gaining by not creating the needed relationship?
What I mean is there is no relationship between the two tables. I can create one on the graph if I need to - but the data itself isnt related.
The layout is a inventory of equipment. So I have a table that stores all the equipment including its type, model, brand, etc.
Then I have seperate tables for TYPE, MODEL, and BRAND so the customer can build a list of those and select them in drop downs. Technically this could just be a value list, but I like having it in tables so they can manage it without needing to go to File - manage value lists.
I am trying to avoid adding a ton of global fields just for record creation if possible.
Global fields aren't really a big deal and are very useful in solutions. I often define a table just for globals when they aren't also needed as match fields in relationships as a way to make it easier to keep track of them.
It’s a good goal. As I said, you’re either going to have to add a relationship or use global fields and an offscreen window.
Remember that the Relationships Graph is not an ERD, nor does it play one on TV. It’s an ERD, a querying tool, and a programming tool. Don’t be shy about adding relationships if they’re needed for functionality. Just because the two tables aren’t related in the data model doesn’t mean two TOs shouldn’t be related on the Graph.
Thanks for the help Mike. I think I was just confusing everyone by saying they arent related. I had no issue relating them on the graph, just meant that they didnt have a primary key and foreign key that align like you typically see with related tables.
Thanks again! I got everything working great with the magic key implementation.