14 Replies Latest reply on Jul 8, 2016 10:04 AM by KerryMiller

    Global Container field won't "save"

    KerryMiller

      I am using a modified form of the method outlined in this post to automate exporting selected records to a formatted Excel spreadsheet.

       

      [ANN] Export custom spreadsheets with FMP2XLS v1.01

       

      While the formatting and styling has proved easy, I am having problems with the Global Container required to hold the Style Sheet.

       

      I place the style sheet file into a Global Container, and the script/method works; but the file is not properly saved. The file does not appear for any other user, and after quitting the database and re-entering the Field is clear.

       

      What could be causing this to happen?

        • 1. Re: Global Container field won't "save"
          coherentkris

          that is the inherent behavior / nature of a global...

          they are isolated to the current users session and return to the default state when the file is closed

          • 2. Re: Global Container field won't "save"
            PeterDoern

            ... one solution being: stop hosting the file, open the file locally, set the global field to the value you want, close the file, and then rehost the file. i.e. the default state of the global field is the state it was in when last opened locally.

            • 3. Re: Global Container field won't "save"
              KerryMiller

              Then how does the template file from the Export Spreadsheet work? It uses a Global Container, and the file it contains loads just fine/as expected.

              • 4. Re: Global Container field won't "save"
                Charlie_Cole

                When a file is hosted on the server the global fields are unique to each user. Meaning that different users can temporarily store data there and when the file is close the data is removed.

                 

                If you want a file to be available to all users stored in that field you must first un-host the database and open it locally and add the file to that field and then close and re-host the database on the server then the file will be there for each use that opens the database.

                • 5. Re: Global Container field won't "save"
                  KerryMiller

                  Charlie_Cole wrote:

                   

                  When a file is hosted on the server the global fields are unique to each user. Meaning that different users can temporarily store data there and when the file is close the data is removed.

                   

                  If you want a file to be available to all users stored in that field you must first un-host the database and open it locally and add the file to that field and then close and re-host the database on the server then the file will be there for each use that opens the database.

                  Hmm. Ok I will have to give this a try.

                  • 6. Re: Global Container field won't "save"
                    coherentkris

                    this strategy works and has worked for a long time in FM but AFAIK its not a documented "feature" so could be changed by FMI at will without notification. If you need to rely on the contents of a global you should really set the value with an OnFirstWindowOpen trigger/script

                    • 7. Re: Global Container field won't "save"
                      KerryMiller

                      Charlie_Cole wrote:

                       

                      When a file is hosted on the server the global fields are unique to each user. Meaning that different users can temporarily store data there and when the file is close the data is removed.

                       

                      If you want a file to be available to all users stored in that field you must first un-host the database and open it locally and add the file to that field and then close and re-host the database on the server then the file will be there for each use that opens the database.

                      Ok. I have tried this method several different ways and it still isn't sticking, but I feel as though I have made progress?

                       

                      The file is still not showing up for any remote users, but the file is showing up when opened directly/locally on the computer we are using to host the Database.

                       

                      In doing this I am occasionally seeing a message that Filemaker is unable to share a file because network sharing is off...

                      • 8. Re: Global Container field won't "save"
                        Charlie_Cole

                        Are you hosting this from a server or sharing from a computer?

                        • 9. Re: Global Container field won't "save"
                          KerryMiller

                          It is being hosted using Filemaker Server.

                           

                          If I copy/move the file it retains the needed file in the container, but if I access it through Filemaker Server it looses it.

                          • 10. Re: Global Container field won't "save"
                            PeterDoern

                            The file is still not showing up for any remote users, but the file is showing up when opened directly/locally on the computer we are using to host the Database.

                             

                            In doing this I am occasionally seeing a message that Filemaker is unable to share a file because network sharing is off...

                             

                            Even if you're opening the database using FileMaker Pro on the same machine running FileMaker Server, you must use Open Remote... to open the file.

                             

                            There is really only one way to try Charlie Cole's method:

                            1. Launch FileMaker Server Admin Console

                            2. Select the database file

                            3. Close the database.

                             

                            4. Using FileMaker Pro, open the file.

                            5. Import the Excel spreadsheet into the global container field.

                            6. Close the file.

                             

                            7. Return to FileMaker Server Admin Console

                            8. Select the database file

                            9. Open the database.

                            • 11. Re: Global Container field won't "save"
                              Extensitech

                              Global fields are definitely an odd beast. Although hugely useful, they're the source of many a misunderstanding in many a thread on this forum.

                               

                              From FileMaker Pro 15 Help::

                               

                              •You can use a global field:

                              •as a fixed value in calculation formulas across all records in a file, or in conditional script steps, such as If, Else, End If, Loop, End Loop, and Exit Loop.

                              •as a match field for a relationship.

                              •You can use variables instead of global fields for temporary data storage. See Using variables.

                              •You can't use a global field to find records.

                              •If your file is shared, only the host's changes to global field data are saved. Changes are saved only when the file is closed.

                               

                              (Emphasis mine)

                               

                              The odd things about a global field include:

                              -A value in a global field can be changed for one user session, and the new value is not visible on other user sessions.

                              -The value in a global field is the same across all records in a table.

                              -A global field can be referenced even in completely unrelated table occurrences.

                              -A global field can be set or retrieved while in Find mode (it doesn't "blank out" when you enter Find)

                              -A global field does not affect a find request (you can use it to set, for example, instructions for the find into a field, without changing what the find will actually do)

                              -A global field cannot be stored. As it states in help, you can use it for relationships, but only on the "near/from" side of the relationship, not the "far/to" side.

                              -Clicking into, or even changing, a global field will not lock the current record; two users can edit a global field on the same record. They won't lock each other out, and they also won't see each other's work. (If they start editing other types of fields, though, they'll lock records in the normal way.)

                               

                              Back pre-FM7, when all database design work had to be done on the unhosted file, the method of storing persistent data in a global kind of took hold, and you can still find relics. The only way to get a global to have a value in it when you first start up is to put something in the global while you have it open with FMP(A) unhosted, and close the file with that value in it. This basically acts as a "default value" in the global field for anyone opening the file after that. This was kind of natural when you had to do all your development unhosted anyway. Now it's a royal pain, and I wouldn't recommend it.

                               

                              Regardless, each user session has its own global values. If one user changes the value in a global, that change doesn't show for any other user. This is great when you're trying to store values just for this one user session, since there's no record locking issues, and you don't have to worry about, for instance, one user changing another user's filter criteria. For persistent data, though, this feature becomes nothing but a hassle.

                               

                              An easier way would be to have a 1-record table (we call ours "system") where you store things like your style sheet. (This is also a great place to put things like the solution name, the info about your own company and contact info, etc.) You can get to that one record from anywhere using a simple cartesian relationship, or as coherentkris said, you can put that value/file into a global onFirstWindow, since the other cool thing about globals is that you can grab them from completely unrelated table occurrences.

                               

                              HTH

                              Chris Cain

                              Extensitech

                              1 of 1 people found this helpful
                              • 12. Re: Global Container field won't "save"
                                KerryMiller

                                An easier way would be to have a 1-record table (we call ours "system") where you store things like your style sheet. (This is also a great place to put things like the solution name, the info about your own company and contact info, etc.) You can get to that one record from anywhere using a simple cartesian relationship, or as coherentkris said, you can put that value/file into a global onFirstWindow, since the other cool thing about globals is that you can grab them from completely unrelated table occurrences.

                                 

                                If I can't get it to work by the Re-host method, I will probably do this. It's not as... elegant as I would like, but it will do the job.

                                • 13. Re: Global Container field won't "save"
                                  Extensitech

                                  I would agree that it doesn't feel "natural", at least at first, but it's definitely more elegant than having to shut down your file just to save a value or file in a global.

                                   

                                  Also, once you have a "system" table (or whatever you call it; I've seen others call it "preferences", "settings", and any number of other things) you'll find it's a great place to store things about the solution itself, so you (or even an administrative, non-developer user) can update these things and change behavior without additional programming.

                                   

                                  An obvious example is your own name and contact info, which you need to show on any number of printed forms. Without something like this, a simple phone number or address change requires a developer, and the developer often has to go find everyplace you've hard-coded that data. With this table in place, and by referencing fields from it on your forms, you can just go to your "system" layout, change the info, and viola, your forms are all up-to-date.

                                   

                                  Less obvious is that over time it'll change how you code requirements like "turn this date red if it's more than three days old". You'll find yourself, for instance, making "3" a system setting, so when the user changes their mind and wants to turn it red after two days, you can say "go to system and change it yourself".

                                   

                                  We maintain a pretty high client/developer ratio, largely because this method allows us to put those sorts of things in our clients' hands, so they can do minor "tweaks" like that themselves, and leave just the harder stuff to us.

                                   

                                  Chris Cain

                                  Extensitech

                                  1 of 1 people found this helpful
                                  • 14. Re: Global Container field won't "save"
                                    KerryMiller

                                    Extensitech

                                     

                                    I ended up using the Single "master" record method to get it to work.

                                     

                                    For anyone finding this thread, here is my solution:

                                     

                                    Made a new Table with a single Record that has two Fields:

                                     

                                    Match ID (used for making a relation to an existing Table)

                                    StyleSheetHolder (A container for holding the style sheet file)

                                     

                                    I then added a sub script to my existing export script that copy/pastes the style sheet from that single record to the Global Container allowing me to use the above linked Excel Export script mostly unaltered (aside from Field names).

                                     

                                    Copying process:

                                     

                                    New Window [ Style: Document ]

                                    Go to Layout [ "StyleSheetContainer" (StyleSheetHolder) ]

                                    Go to Record/Request/Page [First]  //This is probably not needed, but I included it anyway//

                                    Copy [ Select ; StyleSheetHolder::ExcelStyleSheet ]

                                    Go to Layout [ "Product Pages" (Product)] // This is where I have the global container //

                                    Paste [ Select ; Product::StyleSheet ]

                                    Close Window [ Current Window ]

                                     

                                    While... crude. It gets the job done. This could also be run as an "On open" or similar action, but since this only needs to be used occasionally I opted to have it run only when the export script is being run.