Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Store last selected portal row as global variable?

Featured Replies

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!

post-109808-0-59743400-1386561509_thumb.

post-109808-0-94492700-1386561514_thumb.

Does the data in Portal 1 reside in the same table as the data for Portal 2?

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.")

  • 2 weeks later...
  • Author

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.

  • Author

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.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.