September 3, 201015 yr Hi, I am quite new to FM - 1 month, and it seems quite difficult to find an answer to my question in this jungle 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
September 3, 201015 yr 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.
September 3, 201015 yr 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:
September 3, 201015 yr 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
September 4, 201015 yr 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
September 4, 201015 yr 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
September 4, 201015 yr Author It looks in deed very easy. However, nothing happens when I click on the button. Any idea why?
September 4, 201015 yr 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 September 4, 201015 yr by Guest
September 4, 201015 yr 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.
September 4, 201015 yr Author It works as you proposed now, I don't know why, but it works, and it's much simpler. Thx a lot
September 4, 201015 yr 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.
Create an account or sign in to comment