gsg_team Posted October 23, 2008 Posted October 23, 2008 (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! Edited October 23, 2008 by Guest
Fitch Posted October 23, 2008 Posted October 23, 2008 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 )
gsg_team Posted October 24, 2008 Author Posted October 24, 2008 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]
Fitch Posted October 24, 2008 Posted October 24, 2008 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
gsg_team Posted October 24, 2008 Author Posted October 24, 2008 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!
Colin Keefe Posted October 24, 2008 Posted October 24, 2008 (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 October 24, 2008 by Guest
David Jondreau Posted October 24, 2008 Posted October 24, 2008 (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 October 24, 2008 by Guest
Colin Keefe Posted October 24, 2008 Posted October 24, 2008 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.
David Jondreau Posted October 24, 2008 Posted October 24, 2008 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)?
Colin Keefe Posted October 24, 2008 Posted October 24, 2008 (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 October 24, 2008 by Guest
gsg_team Posted October 24, 2008 Author Posted October 24, 2008 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?
David Jondreau Posted October 24, 2008 Posted October 24, 2008 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.
gsg_team Posted October 24, 2008 Author Posted October 24, 2008 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.
Colin Keefe Posted October 24, 2008 Posted October 24, 2008 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 :
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now