7 Replies Latest reply on May 8, 2012 9:11 AM by dloughlin

    CWP and Global fields

    dloughlin

      No big surprise, but I've managed to confuse myself. I was under the impression that Global fields could not be used in a CWP environment, but as I've researched further, I'm reading things that suggest you can.. Is it possible to set a global variable using the API, and that value would be used by all subsequent activities by that user, and that user only? ie: if I set global field value at the time a user connects (thru the API) to an FMServer12 Advanced database, and that field is used as a key field in a relationship, would all subsequent API activities use that global field value? I'm hoping the answer is yes, it will make life a lot easier.

        • 1. Re: CWP and Global fields
          Stephen Huston

          I've never heard that global fields wouldn't work in CWP. (You're getting this from an IWP user.)

           

          Try setting up a simple test file to test only what you are trying to accomplish with that global, and let us know if it fails.

          • 2. Re: CWP and Global fields
            PalmDBS

            Not sure about 12, but you definitely can't read/set global fields from PHP in 11.

            • 3. Re: CWP and Global fields
              dloughlin

              dbmike, not the answer I hoped for, but thanks for the info. The problem I'm trying to resolve is as follows: I have a pretty complex DB, that has some realationships based on the current date stored in a global calculation field, and these relationships are used in calculations. What I need to accomplish is for individual users to be able to use an alternative date (other than the current date). What I would like to have done, was set a global date field, and use that in the realtionship, rather than the global calculation field, and then each user would get a "picture" of the data based on the global value that they set.

              As an alternative, I'm wondering if I could have php kickoff a script that would set the global field (based on a script parameter), and have that same script create records in a separate table that could be used in subsequent finds, queries, etc,, by the user. I guess the question is, can a user kick off a script that sets a global variable (that is used in relationships), and will that global value at least be maintained for as long the script runs? I'm thinking yes, but if anyone has an opinion, that is contrary to that I'd like to know, as it may be time consuming to set up.

              At any rate, I appreciate the feedback I've gotten so far.

              • 4. Re: CWP and Global fields
                datastride

                I believe the issue with global fields and CWP boils down to this:

                 

                In FM11 at least, each time you access thed database via PHP (for example, on each new web page accessed by the user), you are effectively starting a new session. Thus globals fields, though accessible via CWP/PHP, are reset on each access you initiate to whatever value each contained the last time the file was closed when not hosted by FM Server.

                 

                So you can set a gloabl field, but the value will revert on your next access via PHP.

                • 5. Re: CWP and Global fields
                  Malcolm

                  Is it possible to set a global variable using the API, and that value would be used by all subsequent activities by that user, and that user only? ie: if I set global field value at the time a user connects (thru the API) to an FMServer12 Advanced database, and that field is used as a key field in a relationship, would all subsequent API activities use that global field value? I'm hoping the answer is yes, it will make life a lot easier.

                   

                  You are able to set global fields. The value of the global, just as it is in FMPro, is unique to the user for that duration of their session. However, the typical CWP session is transitory. A web user will generate many different sessions within a visit to the web site, effectively, they are a different user each time, so the global value is not available to them from one session to the next.

                   

                  Malcolm

                  • 6. Re: CWP and Global fields
                    mbraendle

                    I wonder whether global fields in a CWP context are necessary anymore. Because one can load tables or subsets individually - and at any time - into PHP or JavaScript variables. Arrays in PHP are associative, so it is possible to build a data structure that reflects the data structure in the database or  any other structure. Furthermore, if you need to retain information from a session to another session, you can store a cookie in the user's browser.

                    • 7. Re: CWP and Global fields
                      dloughlin

                      Thanks for the reply, and excuse my late response. The relationships and the possible data elements they might want to query against, I think don't make that possible, at least for my level of programming.

                      The solution I ended up with accomplishing, was setting using a script which set a global date value, and then by looping, I create each record and then populate field values based on the relationship(using the global date value that is in effect while the script is running). Unfortunately, you also cannot use the import step in a web environment, thus I had to create the records and populate the fields individually. Not pretty or efficient, but it works. Hopefully one day, Filemaker will make Global values available in CWP , and also allow importing.