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.
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.
The script is:
Set Variable [ $fields ; Value:ExecuteSQL ( "SELECT TableName , FieldName FROM FileMaker_Fields WHERE TableName =?" ; "" ; "" ;
"ENV_GLOBALS" ) ]
Set Variable [ $max; Value:ValueCount ( $fields ) ]
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
Set Field By Name [ $the_field; "" ]