Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5874 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted (edited)

Hi all,

I have an issue with my script in its earliest stages.

I go to related records and try to loop through them to simply display the values in a dialog box (with the intention of actually doing something with the fields later).

After the first related record, the loop continues on the original layout instead of the next related record. In one instance, there are 4 related records and I can see them returned correctly in the other window but the last 3 are ignored.

I have to hit esc multiple times to stop the script and I am returned to the original layout somewhere in the middle of the foundset instead of the record I executed the script on.

Please see attached screenshot.

I'm sure it's something completely simple I'm overlooking. Please provide some common sense I'm lacking. Thanks!

gtrr.PNG

Edited by Guest
Posted

I don't like any ambiguity about what window I'm targeting, so I'll typically do something like this:

Set Variable( $window; "name of window" )

GTRR / New Window( $window )

Select Window( $window )

...

Close Window( $window )

Posted

I tried that it didn't seem to make a difference. I also tried selecting the related record in the loop to ensure it was always the one on top. It remains on top and I see the related records but it's still iterating through the original layout instead. I also tried opening the related file first in the script and committing my global field before the loop as well as just getting rid of that line altogether. That also made no difference.


Open File["pricelist01"]

Set Error Capture[On]

Set Variable[$window; Value:"related items"]

Go to Related Record[show only related records; From table: "F Code Package Items"; External; Using layout: "F Code Package Items" (F Code Package Items); New window]

Set Variable[$error; Value:Get(LastError)]

If[$error = 0]

 Go to Record/Request/Page [First]

 Loop

  Select Window[Name: $window]

  Show Custom Dialog [F Code Package Items::Descrip Drop Menu Tabs]

  Go to Record/Request/Page [Next; Exit after last]

 End Loop

End If

go to Layout[original layout]

Posted

Instead of go to layout at the end, you should close the window($window).

Also, the select window should come after the If, above the loop.

FWIW, I prefer to test for related records *before* I GTRR, rather than test for an error afterwards. E.g.:

If( not IsEmpty( related::field )

   GTRR( related records )

End If

Posted

Thanks for your responses. I implemented your suggestions but it does not have any effect. I've also attached a screenshot showing that the related records display while the loop iterates on the original layout in the background. I don't see why this should be happening!

script.png

layout.png

Posted (edited)

Can't tell from your script snippet, but when you GTRR using a new window, are you actually using $window as the window name? Are you spelling it correctly?

[edit] Never mind, I see the window name in the screen shot. I'm not sure that you need Select Window anyway, since you your "related records" window should already be the active one at that point in the script. The only thing I can think of here offhand is that rather than use the variable for your new window name, you're hard coding "related items " with a trailing space or something.

On an unrelated topic, is Descrip Drop Menu Tabs always populated? This script will run unreliably if not, even after you fix this particular problem.

Edited by Guest
Posted (edited)

Here's a test file I put together. It confirms what the OP is saying (you're not crazy). It looks like all the steps are firing correctly, but (with or without the Select Window), but while the new window is in front, the focus is still on the old window and the Go To Next Record applies to the original found set.

I'm sure this has to do with working with multiple files and I'm also sure I don't know enough about multiple files to offer a solution.

Archive.zip

Edited by Guest
Posted

Oops. Yeah, missed the "External" part, good catch DJ.

Here's the issue - you're attempting to run a script in a file the script has no hooks into. It doesn't exist there.

You can go two ways here:

1. Call a subscript in File 2 to do the looping (the way everything was done in pre-7 solutions).

2. Add a TO in File 1 pointing to the table in File 2 using it as a data source, and an appropriate layout, and when you GTRR, use THAT layout.

Which is better just depends on where you want to keep the bulk of your application logic. If the looping functionality in File 2 were to be called from multiple other files, then you'd want a subscript in File 2. If everything is getting handled from File 1, I'd probably go with an extra TO, to keep my scripts sane.

Posted

For my own education, is it accurate to say that you can't run script steps on an external file, unless that script step specifically has the ability to reference that file (frex GTRR[], Select Window[], etc)?

Posted (edited)

Yes, that's pretty accurate. Have you developed in FM 6 or earlier? The script behavior's pretty much the same, with the caveat that window management has to be more explicit.

So GTRR will get a correct record set in the external file, with the layout you specify in that file, but once there you need to call a subscript in that file to perform more operations.

However, you can reference or model the data in the external file using TOs in your first file. This is actually more or less how the "data separation" model works - the data tables and core schema live in one file, and the layouts and scripting logic in an interface file, with TOs pointing to the data source.

As an aside, it's interesting to see a new generation of developers have to wrap their heads around multiple files, when a few years ago, we were trying to wrap our heads around tables in a single file!

[edit] most of that was for the OP, DJ, I get the feeling you've been around the block for awhile.

Feeling old,

Colin

Edited by Guest
Posted

erything was done in pre-7 solutions).

2. Add a TO in File 1 pointing to the table in File 2 using it as a data source, and an appropriate layout, and when you GTRR, use THAT layout.

Hi Colin,

I'm not sure I follow this line. I already have a TO joining file 1 and 2 by "F Code Package Id" which seems to be bringing up the related records in the related items window. Is there a different way to make a relation across files?

Posted

Colin, thanks. I came back (after many years away) to Filemaker right after 7 was introduced, so I missed/forgot all the separate file stuff. I'm just getting into the separation model now and have only needed to perform scripts in the "child files" a couple times.

gsg, what Colin is saying is to build your "F Code Package Items" layout in your "parent" file (Work Orders?), based on the F Code TO.

Posted

gsg, what Colin is saying is to build your "F Code Package Items" layout in your "parent" file (Work Orders?), based on the F Code TO.

Ahh, that worked! Thanks to all that replied.

Posted

gsg, what Colin is saying is to build your "F Code Package Items" layout in your "parent" file (Work Orders?), based on the F Code TO.

Yeah, except you said it with about 1/5 the word count, and more clearly :

This topic is 5874 days old. Please don't post here. Open a new topic instead.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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