1 2 Previous Next 21 Replies Latest reply on Jan 31, 2014 9:38 PM by RossHurley

    Import Script to Update Host File

    RossHurley

      Hi all,

       

      I'm developing my first iPhone system in FM Go 12 and can't get a script to import data back into the host file to work. A copy of the office system is copied to the iPhone in the morning for use out in a farmer's paddock, then the new and revised data is to imported back into the offfice system at the end of the day. I'm following the FileMaker Development Guide to script the updating of the host file and have created the Example 2 script under the Importing to and From a Transferred File heading. The script is built in the host data file and essentially consists of just setting a $Path variable of GetDocumentsPath & "filename" of the file on the iPhone followed by an update/import step using $Path to the source file then an import setup matching on IDs and adding new records. To do the initial testing I'm manually opening the host file from the iPhone and running the import script in that file. Strategic pauses in the script show that it is working up to the import step, but then I'm getting an Error 3 - Command not available and nothing gets imported.

       

      I've checked the $Path variable and it consists of "/var/mobile/Applications/[string of numbers & letters]/[filename]" which I assume is the path on the iPhone to the source file. I've done an internet search and someone said that this example in the Development guide does work but that you have to follow the steps exactly. I've checked and I'm sure I've done that.

       

      Can anyone tell me why it's not working?

       

      Thanks,

       

      Ross Hurley

        • 1. Re: Import Script to Update Host File
          DavidJondreau

          I don't know why it's not working, but you can skip the whole Documents path thing, if you

           

          1) In the mobile file, create a data source to the host file.

          2) Import the mobile file into itself, using the newly created TO as the target.

           

          All the importing will be done from the context of the mobile file.

          • 2. Re: Import Script to Update Host File
            RossHurley

            Thanks David,

             

            That suggestion is certainly more straightforward, but I can't see how I can set it up. It's a separation model system so there's a data file and an interface file. As both data filenames are the same (the iOS file is a copy of the host file) and the file reference has to be set up on the host machine, the file reference is the same as that of the local data file (file:filename).

             

            I also tried making a copy of the system, opening the copy as a guest and setting up the reference to the host (fmnet, IP address and filename) but that also failed. When copied to the iPhone and test new records created, they were not imported back to the host. It would appear the import step failed as there was no message at the end saying how many records were imported and the record count stayed the same. The import script was set up to first go to the layout based on the host file, then import. The import source was the local file reference. I can't see where the error is.

             

            Any further help you can give me in setting up the TO-based import would be appreciated.

             

            Regards,

             

            Ross

            • 3. Re: Import Script to Update Host File
              DavidJondreau

              I'm somewhat confused by your file configuration. Generally, a separation model doesn't require importing. So which is importing into which? And I don't know why you have two files with the same name.

               

              Regardless, the Import[] script step should be run from the iOS device with a source table occurrence of a native table occurrence and a target of a table occurence based on the hosted file. It sounds like you may have gotten close to that in your second paragraph. There's a few reasons an import could fail. You should test this process on a client FM Pro, not a client FM Go, putting the import script through the debugger. If it works on FM Pro, it should work on FM Go.

              • 4. Re: Import Script to Update Host File
                Malcolm

                If it works on FM Pro, it should work on FM Go.

                 

                Thats what it says on the box but we know that the truth lies elsewhere

                 

                Debugging in Pro is the only option we have at present. Its time FMI started saying out loud "Go is different". We don't have a debugging environment that either runs natively on iOS or emulates iOS behaviours. I'd like to have a debugger version of Go coupled with the FMPro Advanced licence.

                 

                Malcolm

                • 5. Re: Import Script to Update Host File
                  wimdecorte


                  Its time FMI started saying out loud "Go is different".

                   

                  They're saying it loud and clear:

                   

                  http://www.filemaker.com/support/product/docs/12/filemaker-go/fmgo_development.pdf

                  • 6. Re: Import Script to Update Host File
                    RossHurley

                    Thanks for all your responses. Yes, the lack of any debugger in FM Go is a 'b**gger' if you'll excuse the French. I'll keep trying and will post the answer if I get it to work.

                     

                    David, the system is on an iPhone so the farmer can do data entry when he's out on the farm - a long way out of network reach. Hence, both data and interface files must be copied to his iPhone each day. It's when he's back within the network that the new and revised data must be imported back into the host data file.

                     

                    Ross

                    • 7. Re: Import Script to Update Host File
                      DavidJondreau

                      Is the farmer linking to just his own data or are there multiple farmers all syncing data to one database? Is the farmer simply collecting new data or does she need to access existing data while in the field? In other words, do the host file need to move its data to the iPhone in the morning?

                       

                      There are ways of doing this yourself, an import is the simplest way. In your iPhone interface file, you should have a reference and a TO to the iPhone data file and the host data file. The import script simply uses as a source the iPhone data file and targets the host data file. The failure of your attempt isn't a problem with the strategy but with the implementation.

                       

                      To diagnose that, you'd need more detailed help than we can probably give here. Namely, hands on access to all three files as currently set up (hosted) and it would take a couple hours.

                      • 8. Re: Import Script to Update Host File
                        Malcolm

                        Describe the office setup.

                         

                        Is it running Server or is it FMPro client on a local machine?

                        Are there multiple copies send to the paddock on different iphones?

                        Is there someone in the office using the databases while farmer  is out in the paddock?

                        • 9. Re: Import Script to Update Host File
                          RossHurley

                          David and Malcolm. Your questions were similar. It's a 2-person show: the wife who maintains the main database in the home and the husband who wants to enter data while he's out in the paddocks on his iPhone - at this point just stock movements. In practice the updating process is only occurring weekly. There aren't enough stock movements to do this daily.

                           

                          Yes, the main database will also be modified during the day. At this stage I've just got the wife overwriting the old iPhone files with the updated host files using iTunes. When I get the updating from iPhone to the main system working I'll add to the script the reverse process of updating the iPhone with the main system data.

                           

                          For stock movements the only data the farmer needs on his iPhone apart from the actual movements records is stock and paddock data, for value lists. The files are small enough to copy over in toto in seconds, and it enables me to add further functionality to the iPhone easily if/when he requests it. A smaller subset of the system could be used but that just increases the work, having to write further functionality into the files instead of just providing access to existing functionality.

                           

                          It's a simple one-file FM Pro setup sharing 'peer-to-peer', not server.

                           

                          The outlne of the process in your second para, David, is what I'm doing. I've got 25 years of experiene with FMP and couldn't count the number of import/export scripts I've produced in that time, so I'm surprised there's something here I haven't got right. But the inability to develop in FM Go and having to do it all on the host machine (or a two-machine setup I haven't tried yet) and the lack of a debugging facility on the FM Go side makes it more difficult. I have checked and rechecked the way I've set it up and can't find why it's failing. It's at the import step - it just doesn't import any data.

                           

                          Thanks for your continued interest.

                           

                          Ross

                          • 10. Re: Import Script to Update Host File
                            Malcolm

                            It seem like the data that has to go from the paddock back to the host file is stock movements. If so, why don't you export via CSV and email that or share it via dropbox. The home computer can import the CSV and the updated data file can be passed back to the iPhone by itunes or dropbox.

                             

                            Another thing to consider is that it is still possible to stack file references. If you have a data separated file you can have several reference to the data file, stacked in order of preference.

                             

                            The references  from the UI file to the data source may look like this:

                             

                            file:/desktop_data.fmp12

                            file:/ios_data.fmp12

                             

                            Malcolm

                            • 11. Re: Import Script to Update Host File
                              RossHurley

                              Malcolm,

                               

                              That's basically what's happening now. The wife saves the modified iPhone data file back to the Desktop of the host computer in iTunes and then runs a script in the host data file to do an import of the revised/new data.

                               

                              I understand stacked file references but I'm not sure of the relevance here. To find the host data file, just one reference is needed, to set up a TO to this file/table into which the updated data is to be imported. I've set this up using Open Remote and it's a file:IP address/filename reference. Just a file:/filename reference would find the local data file, not the host file.

                               

                              Ross

                              • 12. Re: Import Script to Update Host File
                                Malcolm

                                I understand stacked file references but I'm not sure of the relevance here.

                                 

                                I suggested them because (in response to David) you had said:

                                That suggestion is certainly more straightforward, but I can't see how I can set it up. It's a separation model system so there's a data file and an interface file. As both data filenames are the same (the iOS file is a copy of the host file) and the file reference has to be set up on the host machine, the file reference is the same as that of the local data file (file:filename).

                                 

                                Perhaps you want to have more than one data source. Is it possible to separate the data so that there are two data sources? One for data that changes in the paddock, the other for data that changes in the office. To bring both up to date you simply push data file A from iPhone to Office and push data file B from office to iPhone.

                                 

                                malcolm

                                • 13. Re: Import Script to Update Host File
                                  RossHurley

                                  Thanks for the suggestion Malcolm. It's worth considering, ie separating out the table that the farmer uses in the paddocks. I haven't looked at it, but I presume Save Copy As is available as a scriptable option to run from the iPhone, to save and replace the separated table back to the office. And, without looking at it, perhaps 'Open File' to open the main data file followed by a 'Save Copy As' to replace the existing file on the iPhone. All operations have to be run from the iPhone because computers can't see files on iOS devices.

                                   

                                  This is the most workable solution yet, and the import problem would become academic. But I'd still be nagged by it until I found out what the problem was.

                                   

                                  Ross

                                  • 14. Re: Import Script to Update Host File
                                    Malcolm

                                    This is the most workable solution yet, and the import problem would become academic. But I'd still be nagged by it until I found out what the problem was.

                                     

                                    The main thing is that you can shift the issue from the box marked "must be resolved" to one marked "rainy day".

                                     

                                    malcolm

                                    1 2 Previous Next