5 Replies Latest reply on Sep 26, 2014 10:21 AM by wimdecorte

    Reseting Served File Global Defaults

    coherentkris

      I have been researching how to reset global field defaults when a file is served.

      I understand that the file retains the value in the global field when the file was last opened locally.

      I understand that running any kind of scripted action on the globals when the file is served only changes the values for my session.

      I understand that the best way to reset the defaults is to open the applicable file locally and manually change the value.

      I have been able to find two post from reputable developers (Mr Robertson and Mr Jondreau) that suggest the defaults can be reset via server side script.

       

      http://comments.gmane.org/gmane.comp.db.filemaker.devel/35414

       

      http://fmforums.com/forum/topic/87308-globals-reverting-on-server/

       

      I have attempted this and the defaults were NOT reset.

      The server side script was assigned to run with a full access permission set and did not return any errors.

      Any ideas?

       

      The script is:

       

      Set Variable [ $fields ; Value:ExecuteSQL ( "SELECT TableName , FieldName FROM FileMaker_Fields WHERE TableName =?" ; "" ; "" ;

      "ENV_GLOBALS" ) ]

      Set Variable [ $max; Value:ValueCount ( $fields ) ]

      Loop

      Set Variable [ $counter ; Value:$counter + 1 ]

      Exit Loop If [ $counter > $max ]

      Set Variable [ $the_value ; Value:Substitute ( GetValue ( $fields ; $counter ) ; "," ; "¶" ) ]

      Set Variable [ $the_field_prefix ; Value:Left ( GetValue ( $the_value ; 2 ) ; 2 ) ]

      Set Variable [ $the_field ; Value:Substitute ( $the_value ; "¶" ; "::" ) ]

      If [ $the_field_prefix = "__" or $the_field_prefix = "zz" ]

      #do nothing to these fields

      Else

      Set Field By Name [ $the_field; "" ]

      End If

      End Loop

        • 1. Re: Reseting Served File Global Defaults
          wimdecorte

          Do it the proper way instead of trying to rely on very implicit behavior:

           

          - store the desired values in a table in non-global fields, a preferences or settings table

          - have the OnOpen script load those values in globals

          1 of 1 people found this helpful
          • 2. Re: Reseting Served File Global Defaults
            jimfeuerstein

            Global values on a server can be reset by script. However, those new values persist ONLY for the session during which they were set. Thus, if you want a particular value for a global during a user's session, you should set that value during the user's startup script. (And don't use Perform Script on Server for that purpose, since a PSOS script has its own session).

            • 3. Re: Reseting Served File Global Defaults
              coherentkris

              Wim,

              Please explain what you mean by "very implicit" behavior. Does this suggests that the method should have / could have worked?

              I thought that I knew how globals operated at a fairly deep level but the posts by our colleagues pointed to a knowledge gap that I want to close.

              I assumed that the Server Side Scheduled Script I posted would run in the context of the server session only and the default values would remain untouched. Same with the script run as PSOS from the client.

              I tested both and they failed to change the global defaults... which is contrary to the postings but what I was expecting.

               

              Any insight?

               

              PS I changed the defaults by changing the field definitions from global to calc-unstored, saved the field definition, then changed the field definitions back to globals and it reset the defaults.

              Time consuming but it worked.

               

              Thx,

              K

              • 4. Re: Reseting Served File Global Defaults
                BruceRobertson

                In previous versions, it was consistently the case that running a scheduled server script to reset globals would allow all users who logged in after the scheduled script would see the new values. That is no longer the case.

                 

                Just use a script. Get over the idea that you can select magic behavior.

                • 5. Re: Reseting Served File Global Defaults
                  wimdecorte

                  coherentkris wrote:

                   

                  Wim,

                  Please explain what you mean by "very implicit" behavior. Does this suggests that the method should have / could have worked?

                   

                  No, I was referring to the behaviour as not explicitly "being a feature".

                  As Bruce explained, this type of implicit behaviour can come and go with each version, but since it is not an official feature you should not build your solution on it.