10 Replies Latest reply on Jun 18, 2015 10:34 AM by philmodjunk

    Fields clearing after I restart

    bruns

      Title

      Fields clearing after I restart

      Post

      I have an older database and the script is working fine.  Both in FMP 11.  I retyped the same script, built the same layout and files.  There are only 2 files, expire date which is a date field global and expired which is a text field global.

      If I close the database and reopen it, it clears the fields and I want the data to stay.  In my script I am using a Ser Variable $DateOK.  However the new database is hosted on FMP11 Server, do I need to change to $$DateOK?

        • 1. Re: Fields clearing after I restart
          philmodjunk

          You refer to a global field from a database that is hosted from FileMaker Server. Is this the field that does not retain a value when you close the file?

          This is expected behavior for global fields in a hosted database.

          http://help.filemaker.com/app/answers/detail/a_id/3604/kw/global

          PS. I can't tell from your post what roles variables play in your issue here, but no variable, whether $$Global or $Script will retain a value when the file is closed.

          • 2. Re: Fields clearing after I restart
            bruns

            Yes, both fields are global and when I restart the data disappears

            In the local database not on server fields are same but do not disappear.

            As you can see in my script, I am trying to put a protection in line .  If you have a better idea, I would appreciate your thoughts.

             

            • 3. Re: Fields clearing after I restart
              SteveMartino

              There's some confusion with $DateOK, and $$DateOK (which I don't see at all in the script).  $$DateOk would have to be initialized when the user starts a session.

              Also in your script, you set the $DateOK variable, but you don't follow up with Set Field

              • 4. Re: Fields clearing after I restart
                bruns

                I do not have $$DateOK in my script, I just thought that might be my problem.

                I just looked at the script from the database that this works in and it does not have a setfield after that first Set Variable.

                 

                Is there any way I can make this better?  Or work.

                • 5. Re: Fields clearing after I restart
                  philmodjunk

                  You'll need to explain exactly what this script is supposed to do, What layout is current when this script runs (on what table is it based?) and how your data is set up in tables/relationships.

                  I don't see any fields in your script that should be defined as global fields.

                  EXACTLY what fields appear as blank when you re-open the file?

                  This might simply be a case that your found set is not retained when you close/re-open and thus the current record on your screen is not the same record that you had when you closed it.

                  • 6. Re: Fields clearing after I restart
                    bruns

                    That last part is correct, when I close the database it is on the last record I was on, when I open database, it is on the first one.

                    • 7. Re: Fields clearing after I restart
                      philmodjunk

                      This is typical of a hosted database. The simplest solution is to set up a script performed by the OnFirstWindowOpen script to select both the correct layout and the correct record before it does anything else.

                      Show All Records
                      Go To Record/Request/Page [Last]

                      • 8. Re: Fields clearing after I restart
                        bruns

                        What I am trying to do is put a script together that has a date is the future that if someone with full access can keep changing but if they let everyone go with full access that the database would close once that date was reached.  The developer that assisted before had the date field and the expire field set as global, do they not need to be global?

                        • 9. Re: Fields clearing after I restart
                          bruns

                          I put a closing script in with

                          Show all records

                          Go to Layout Equipment

                          Go to Record/Request/Page [First}

                           

                          Opening Script

                          Show all Records

                          Go to Layout Equipment

                          Go to Record/Request/Page [First]

                           

                          I changed from global to not global on both fields

                          Still clears fields

                          • 10. Re: Fields clearing after I restart
                            philmodjunk

                            I know very little about your database and what you are trying to do.

                            All I can see is that you have a script that checks the value of a field from the context of a single record--probably from a layout based on a table occurrence named "Equipment" but I can't be sure of that from what I see here. You've indicated that you have multiple records in this table and that you want the above script to  run from the context of the last record in this table.

                            Thus, I have suggested a way to make sure that the above script runs from a context of the last record in the table.

                            Beyond that, you'll need to keep in mind how little I know about your database and what you are trying to do.

                            What you describe does not sound like a date to store in a table named equipment. Instead, this sounds like a value that should be stored in a separate table with just one record. Your start up script can either just go to a layout based on that table to check the expiration date or it can copy the value to a global field or variable to make it accessible from all layouts, scripts in your file.

                            But I must also observe that if the people with full access are not the owners of this intellectual property, this set up could be seen from a legal stand point as "employee sabotage" much like an employee setting up the only full access password on the file and then not communicating this password to management when they exit the company for any reason.