September 1, 20169 yr Newbies Hello, Our school district has recently started to use Filemaker to automate some student data functions not available in our student information system. I have run into an interesting problem when exporting tables based on found sets. When running the script using the server Schedule Scripts function, the export table seems to be ignoring the found set I have created in a layout. I have tested the same script functions in the same order in the client and I get an exported CSV that is based on the found set. Is there something I am missing in regards to context? I have read some of the documentation on the Filemaker site. It seems to state that there is no current context when the script runs, but I am loading a layout which I have then applied a Perform Find and then export using the same table as the layout. Any insight would be helpful. Mike
September 1, 20169 yr The Server is not the same user as you. Imagine a completely newly opened file every time the script runs - that's what the Server uses. The script must perform it's own finds and sorts and whatever else to get the correct set to be used - you can't do it on your machine and expect it to use that.... Hope this helps
September 1, 20169 yr Author Newbies Hi, From my reading I think I understand the interactions and the server user vs the client UI. Here is how my script(s) are setup. Go to Layout [ "Active SD95 Staff" (tbl_StaffInfo) ] (onLayoutEnter if performs a find on a employee status field) Set Variable [ $lbfilename ; Value: "/LunchBox/LB-SD95Staff.csv" ] Set Variable [ $lbfileloc ; Value: "Get ( DocumentsPath ) & $lbfilename ] Export Records [ No dialog ; "$lbfileloc" ; Unicode (UTF-8) ] (this exports 8 fields from tbl_StaffInfo, no related fields) It appears to me that the Export Records function does not use the current layout context and just exports the raw table. I should have 179 records, but the file on the server has 386 records. Using the same script steps in the client, I get a file with 179 records. Is my code or thinking wrong? Other scripts that generate passwords, change status field, or import records all work as expected. I am experiencing this with all my scripts using the Export Records on the server. This is our first attempt to use Filemaker with automated exporting, so maybe I am missing something. MikeM.
September 1, 20169 yr I tend not to use script triggers that are based on layout enter unless absolutely necessary because they can fire when you are not expecting it. How about: Set Variable [ $folder ; Get ( DocumentsPath ) ] Set Variable [ $filename; "YourFilename.csv" ] Go To Layout [ whatever ] Enter Find Mode [ ] Set Field [ YourField ; "Active" ] Perform Find [ ] Export Records You can run this on the client or the server and both should return the same results.
September 1, 20169 yr Author Newbies That worked a lot better. At some point I tried just the Perform Find alone and without success. I appears putting the layout into Find Mode makes the export work. Thank you for showing me a different approach. MikeM.
Create an account or sign in to comment