mdavis6537 Posted December 9, 2013 Posted December 9, 2013 Hello,   Trying to add records in a portal and have them link to a specific foreign key. Normally filemaker would do this automatically, but the layout I am on is not the table I am trying to link these new records to. The reason is because I already have another portal on this layout, and I need to add records to it as well. That portal, is the one I need to link my second portal to.  So I have my first portal, which is working fine, called levels ( as in levels of a house ie Basement), then I have my second portal, rooms. I have a select button on the first portal which, when clicked, executes a script that saves the primary key to a global variable. Then when I create a new portal record on my second portal, it runs a script that sets that saved primary key as ITS foreign key.  But - it doesnt work. The records get all kinds of weird results. Mostly, it seems like the newly created records are always linked to the primary key of the FIRST record in my other portal, rather than the one I selected last via my button.  How can I make this work? Right now my work around is sending the individual to another layout, which looks exactly like this layout but is linked to the correct table. But that method isnt that great, because it confuses the user when they now cant add records to the first table without hitting a button.  Any help would be greatly appreciated!
Melinda O'Brien Posted December 9, 2013 Posted December 9, 2013 Does the data in Portal 1 reside in the same table as the data for Portal 2?
Fitch Posted December 10, 2013 Posted December 10, 2013 Instead of, or in addition to, the global variable, you could set a global field to the selected level ID, and then make a relationship from the global field to the rooms, and use that relationship for the rooms portal. That's a pretty standard construction for pick lists in FileMaker-land. (BTW, I believe it would be more correct to say "Affected" rather than "Effected.")
mdavis6537 Posted December 18, 2013 Author Posted December 18, 2013 Thanks both of you for the replies, sorry its been so long since I have replied - I have been out of town. @Melinda - No, these two portal both go to seperate tables - one for the "Levels" of a house and one for the "Rooms" in the house. @Fitch - Can you explain a bit more about this global "Field" ? Would I just put it under the same table as the Level ID or does it need to be on its own? I am going to play around a bit with that idea now and I will just make a table called Global for now. I guess I just dont get why my global variable method isnt working. When I cilck off of the first portal, is it resetting my global variable to be null? Seems like that global variable, $$DryLevelID, would just stay the same as whatever the last thing was that it was set to - but somehow it is resetting when I leave the portal it seems. Again thanks for the replies.
mdavis6537 Posted December 18, 2013 Author Posted December 18, 2013 UPDATE - Well I was able to get it working - but somehow I feel I am not using the best way. I couldnt figure out the relationship piece, but I was able to create a global Level ID Field, by itself in a table called globals, and through scripting I am able to create a new room and link it to my Level by using that global field. So that works! Still interested to see how that relationship setup works though as I am sure that is a better method.
Recommended Posts
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