logo
Just for fun... click:
 
 
 

Set FileMaker Field Using Variable for Field Name

-- Demo script to roll back a data table from a transaction log
--
The script works on a file with 2 tables, "Log" and "Data"
-- Start with 2 windows open

tell  application "FileMaker Developer"
   
activate -- bring FileMaker to front
   
go to  document "SetDataFromLog.fp7" -- bring database file to front
   
tell  document "SetDataFromLog.fp7" -- document = found set
      
tell  window 1 to  go to  layout "Data"
      
tell  window 2 to  go to  layout "Log"
      
tell  window 2 -- Log
         
-- Extract the data from the log table into 3 arrays
         
tell  layout "Log"
            
set  the_field_names  to  field "FieldName"
            
set  the_field_values  to  field "Value"
            
set  the_IDs  to  field "ID_Contact"
         
end  tell
      
end  tell
      
set  the_count  to  count  of  the_field_names
   
end  tell
end  tell

tell  application "FileMaker Developer"
   
tell  database "SetDataFromLog.fp7" -- database is the entire database
      --
Loop through the arrays that were created earlier
      
repeat  with  i  from 1 to  the_count
         --
Extract the data from the 3 arrays that were created earlier
         
set  a_field_name  to  item  i  of  the_field_names
         
set  a_field_value  to  item  i  of  the_field_values
         
set  an_ID  to  item  i  of  the_IDs  as  string
         
show (every  record  whose  cell "ID" is  an_ID) -- use key to find record to update
         
delay 1 -- second -- slow script for the demo
         --
The next line sets a field base on a variable
         
set  cell  a_field_name  of  current record  of  window 1 to  a_field_value
         
delay 1
      
end  repeat
   
end  tell
end  tell

 

Valid XHTML 1.0 Strict