Skip 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.

Get a related field content from a portal

Featured Replies

Hi, I am quite new to FM - 1 month, and it seems quite difficult to find an answer to my question in this jungle :P even it might well be quite simple for you guys. So thx for you answer.

1)Is it possible to use a variable with a "go to related record" - Something like "Go to related record ($Exam)" in a script?

2)How could I turn my script to get a field content value from a related TO without using GTRR and then come back to my initial layer?

Thx

1)Is it possible to use a variable with a "go to related record" - Something like "Go to related record ($Exam)" in a script?

No. The destination table occurrence must be selected in the GTRR script step. However you could set up a switch using If statements and select the GTRR step based on a variable, but the logic would have to already be set up. (How often to new tables get added anyway?)

2)How could I turn my script to get a field content value from a related TO without using GTRR and then come back to my initial layer?

Field contents can be retrieved in several ways. If it's the first related record then just ask for the related field directly. If it's a field in the nth related record you could use the GetNthRecord() function. The GTRR step is only necessary when you want to change to the related table an select the related records.

Hi Bilbo, welcome to FM Forums!

In additional to what Vaughan said, I would add that the way to use a variable with a GTRR is to have a global field on the parent side; sometimes in addition to the standard keys with the relationship. You can then set the global with your variable results and GTRR to child data or, what you were asking in your second question, use the global to FILTER the existing relationship to pinpoint the data you want to retrieve (no need to go there using GTRR).

You can filter using the global or, since you have vs. 11, you can also filter your portal itself. But it would help to know more specific example. :wink2:

  • Author

Thank you both of you for your promt and nice answers.

To make my needs a little clearer, I have made a filemaker example. I need to press on a button in the portal to import selected Rapport::Conclusion to the Consult:Report Conclusion. But I have to be back on this layout and smae record at the end of the script. The button linked script is empty now. Would you be kind enough to write a few lines of code for me? I would be extreamly grateful for that.

Thanks a lot.

Patients.zip

Would this work for you?

PatientsC.zip

  • Author

Thank you very much for your proposition, but unfortunately your solution is not exactly what I need, because I don't want to get all the conclusions.

In fact, I want to select only one single report record from the portal using the button and then I need to import the related conclusion (ie. Report::Conclusion) from this report to my Consultation::Report Conclusion. In other words, my Consultation::Report Conclusion field should contain only one single conclusion from a report that I have decided to select.

Could you please help me again? Thanks

Patients.zip

That's very easy - but I wonder if it's a good solution for what you need (which is not quite clear). Suppose there are 2 users, and each selects their own conclusion - what then?

PatientsS.zip

  • Author

It looks in deed very easy. However, nothing happens when I click on the button. Any idea why?

I don't know - it works for me. How about this version?

PatientsScript.zip

  • Author

Version 11.0v1 on Windows XP. This is strange...

But I think I have the script, please have a look at the attached file.

But still I have a small problem:

#Script working fine

Set Variable [ $$PortalRowNumber; Value:Get ( ActivePortalRowNumber ) ]

Set Variable [ $$Conclusion; Value:GetNthRecord (Report::Conclusion; $$PortalRowNumber) ]

Set Field [ Consultation::Report Conclusion; $$Conclusion ]

Same Script, but I am using a variable ($$RelatedLayoutConclusion) instead of Report::Conclusion at the line 4 of the below script, but

now the displayed result is "Report::Conclusion". Why doesn't it work?

Set Variable [ $$PortalRowNumber; Value:Get ( ActivePortalRowNumber ) ]

Set Variable [ $$RelatedLayout; Value:GetLayoutObjectAttribute ( "Portal"; "source" ) ]

Set Variable [ $$RelatedLayoutConclusion; Value:$$RelatedLayout & "::Conclusion " ]

Set Variable [ $$Conclusion; Value:GetNthRecord ($$RelatedLayoutConclusion; $$PortalRowNumber) ]

Set Field [ Consultation::Report Conclusion; $$Conclusion ]

[color:brown]

In other words, can we use a variable as fieldName? Something like that: GetNthRecord ($$RelatedLayoutConclusion; $$PortalRowNumber)

Patients_Copy_1.zip

Edited by Guest

Sorry, I am not going there. I would concentrate on finding out why my two examples don't work for you, instead of trying something that is 10 times more complicated than it needs to be.

  • Author

It works as you proposed now, I don't know why, but it works, and it's much simpler.

Thx a lot

Don't keep creating global $$variables. These consume memory and their scope extend outside the script. Use local $variables instead, unless there is a compelling reason for the data to persist.

  • Author

Thanks a lot Vaughan, I'll follow this advice.

Update to 11.0v2 as well. :P

  • Author

ok, thx

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

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.