2 Replies Latest reply on Jan 22, 2017 7:59 AM by siplus

    How can I do for saving basic customized settings as global variables in my .fm12 file?

    jiang_aq

      I built a simple CRM system, having some basic settings as global variables, how can I save these data in my file? Should I have to create another database for saving these settings?

       

      Thank you!

        • 1. Re: How can I do for saving basic customized settings as global variables in my .fm12 file?
          schamblee

          The data can be hard coded into scripts.  If the data changes then yes you would have to store the data in a table.  I usually create a system table to house this type data.     I also use global fields (logos - containers) , then in a startup script I will copy the data from a regular field to a global field.  

          • 2. Re: How can I do for saving basic customized settings as global variables in my .fm12 file?
            siplus

            Globals are a special beast.

             

            They are

             

            - unique to the current user

            - lose their current value when database is closed

            - on startup they return to the value they eventually had when you shared the database for the first time

             

            Back to your problem,

             

            you should have a settings table with 1 record per user, maybe identified by get(PersistentID), where you store the value of globals in real fields and retrieve their values on startup.

             

            on startup, SetVariable $$ID to ExecuteSQL("SELECT pid from Settings WHERE pid = ? ";"";""; Get(PersistentID)).

             

            If IsEmpty($$ID), create new record, if not, put $$ID into a global and GTRR to fetch the global values from static fields.