1 2 Previous Next 19 Replies Latest reply on Feb 11, 2016 10:15 AM by PieroF

    Variables and Window activations


      Hello, I have a question: is it possible to use a global field or variable that holds different values in different windows for the same table ?


      Why do I need it ? because my global field is a key to a relation to a separate table, and I'd like to use different key values and related records, in different copies of the same window. For example, using a script to search and modify the current set in only one of the windows.


      Instead, as far as I know, a global field can only be global to ALL instances of a table and to ALL activations of a window.

      Or possibly I’m missing an obvious solution…


      Thanks in advance for your help




      Note: I'm using FMP Advanced v14.0.4 on a MacOS X 10.10.5.

        • 1. Re: Variables and Window activations

          A global field holds the same value for every record in the table. Since the field contents of the records in a table are the same, regardless of the table occurrence, a global field does not seem to meet your need.


          A global variable retains its value, until replaced by another Set Variable script step. However, it can hold multiple values; either as return-delimited values, or in repetitions, like a repeating field. The various values could be used as portal filters for your windows. This would mean a fairly rigid, static structure, but might work. Perhaps do a Cartesian Join on your tables, and use the values in a global variable to filter the portal for the record set you are after, given the layout and table occurrence.


          This all sort of begs the question of why you aren't just performing a find for the desired record set, when you open the new window.

          • 2. Re: Variables and Window activations

            Do you just want a way to use data in your solution to change your relationship dynamically?

            • 3. Re: Variables and Window activations

              First of all thanks for your immediate answer...!

              You suggest to use return-delimited values or repeating fields; using repeating filed, each repetition "describing" a window occurrence (window name, key value), is exactly what I was trying (the script is already working): but I ran into the problem of HOW to show the correct repetition in each different window.


              Why do I not perform a standard find ?

              This is always possible, but in my "global" DB (where everything can be recorded: books, CDs, special files, real life document folders, etc.... each item identified by a unique key or label) I've already implemented a more user oriented solution for searching sets of keys entered by the user. E.g. the user simply reads preset labels on physical objects and enters them (e.g. b10-12,16,21 to mean 5 books b10, b11, b12, b16, b21) into a global field in a popover, then the system parses this input and generates a key in the form b10¶b11¶b12¶b16¶b21, used to select the related records. This works just fine and makes this kind of searches very fast and convenient, and easily adjustable to the needs of the user.

              The problem is that if I duplicate the window I see the same searching global field in the searching popover in all windows, while i'd like to keep them different, each window with its own list of keys that I can reuse or modify later in that same window... I'm not sure I'm clear...


              Anyway, I understand there is no such "global" variable that is window activation dependent, that it would help me in this case.


              Thanks a lot



              • 4. Re: Variables and Window activations

                Hi, sorry I'm not sure I understand, but probably my answer to plegler above may explain what I'm looking for.

                • 5. Re: Variables and Window activations

                  I think that the only way to have different results in a window based on certain table occurrence is to use found sets.

                  • 6. Re: Variables and Window activations

                    Yes, that's my understanding too: different windows for different table occurrences with the same layout share almost everything, but the found set and its sorting order. I hoped global variables or global fields could also be "local" to the occurrence, but this seems not to be the case...

                    • 7. Re: Variables and Window activations

                      But found sets are a powerful way to do things like you talk about, do you know how, could you use some suggestion? Are we leaving out the idea of not using the same table occurrence, but one similar, then controlled by dynamic choices or something matched field? Scripts can help with this.

                      • 8. Re: Variables and Window activations

                        Aside from the method of using different windows for displaying different sets of records, it appears that you are wanting to use a portal, hence the idea of a relationship that can be changed.


                        There are many ways of changing the primary key of a relationship.  The obvious way is to use a script and set it directly.


                        A primary key doesn't have to be a global field though.  It can be a calculated field, even an unstored calculation field.  Trouble with an unstored calc field is that you need to ensure that it's updated reliably before the portal is viewed.  Just opening a new window isn't quite enough, but if you "Refresh" the window after opening it, the unstored calc will update itself and the portal's content will display alternate results.


                        I'm not suggesting you do things this way.  Rather I would use a script that creates a new window, sets the key field, and then refreshes the display.  I made a demo file to test this.

                        • 9. Re: Variables and Window activations

                          If you show results in a portal and update matched field will the other window remain unchanged? Of course while viewing both at the same time. This is an interesting topic.Thanks

                          • 10. Re: Variables and Window activations

                            That's a good question.


                            In my test file (download it to check), the original window shows the portal according to the key value there, yet the second window shows different results.  Because the key field is unstored, it appears that it can actually do double-duty.  If you have the Data Viewer open and set to show the key field, it will alternate between two values according to the active window!



                            • 11. Re: Variables and Window activations

                              Unfortunately I don't know a way to attach a .fmp12 file here (200KB).


                              Starting from the RalphLearmont Idea.fmp12 file, I prepared a slightly different example that I'm pretty sure explains what is my point. In fact my problem is different from what is shown in RalphLearmont example, but thanks to him I found a better way to explain it than using many words...


                              So if you teach me how to attach my sample file here I'll do it (the only way I found seems to create a new discussion...). Else I can use We transfer...





                              • 12. Re: Variables and Window activations

                                To attach a file, begin your reply and if you look to the top right hand side of the Editing box you will see in faint blue, the words "Use advanced editor".  Click that...


                                Now there are additional options. 


                                Look down to the bottom right corner and you will see the words "Attach".  Click that...




                                • 13. Re: Variables and Window activations

                                  Thanks Ralph!

                                  Now, my attached example is a stripped down version of my DB: here the key is just a single character, as in your Idea.fmp12, while in my DB it is a more mnemonic label used on physical objects (books etc.), as mentioned earlier in this thread. In my example the point is that, after making a second window, while I may have a different found set in it, I can only see te same value in Key in both windows: the last I used.

                                  Instead I'd like to have each window holding the original key.

                                  Note: here this global Key is used for a relation, but my original question was broader: is it possible to use a global field or variable that holds different values in different windows for the same table ?

                                  The answer seems to be: no, a global field or variable has a unique value independent of the number of table occurrences.

                                  Can you confirm ?





                                  • 14. Re: Variables and Window activations

                                    FWIW, there might be some overlap with this thread from several months ago: Re: Unable to retrieve a repetition based on number in window name


                                    Chris Cain


                                    1 2 Previous Next