1 2 Previous Next 17 Replies Latest reply on Mar 14, 2015 6:33 AM by wfgclapp

    Export single record from FM Go to FM Server w/unique filename

    wfgclapp

      Couple of weirdo things going on here, i.e. obviously things I don't understand. I've read lots of posts on exporting records but I've not been able to crack this. I hope maybe someone out there can recognize something I'm doing wrong.

       

      I want to a user on Filemaker Go 13 to export the contents of a single record to a file on FM 13 Server. And I want to use a field or two in the exported record to generate the file's name.

       

      I don't really care about the file format I guess, but tab or custom delimiter would be best.

       

      Here's as far as I've gotten:

      1. I can get a file on the server but...

            a. The file contains multiple records. In fact it contains all records created in that table 'today'. But none others.

            b. I am using Set Variable for the filename: "filewin:"&Get ( DocumentsPath ) & Order Edits::Sequence & "fmchange.txt"

                  i. Notice I'm using a field as part of the name. But this does not work. No file will be created. But...if I remove the field from the filename and use Set Variable as: "filewin:"&Get ( DocumentsPath ) & "fmchange.txt"     then a file named 'fmchange.txt' is successfully created.

                 ii. Wonder why using a fieldname doesn't work?

       

      Below is my script and the two subscripts that script calls.

       

      Does anyone see anything glaring I'm doing wrong? Thanks much for any help!

        • 1. Re: Export single record from FM Go to FM Server w/unique filename
          schamblee

          The Get(DocumentPath) on FMGo does not refer to a path on the server. Get(DocumentPath) gets the Document Path of the local device, which is not on the server of any device running FMGo.    Your script shouldn't create a file on the server using a variable or a field because of the path you are using.  Filewin will not work on FMGo either, that is used for windows path. 

          Here is a link to the Filemaker Development Guide https://www.filemaker.com/support/product/docs/filemaker-go/fmgo_development.pdf

          • 2. Re: Export single record from FM Go to FM Server w/unique filename
            greglane

            Each time you call a script with Perform Script on Server, the script starts with a new environment. So, the second script does not have the same found set as the previous script. I'd suggest combining your two server-side scripts or create a new server-side script that will call your two existing scripts using a regular Perform Script.

            • 3. Re: Export single record from FM Go to FM Server w/unique filename
              wfgclapp

              schamblee wrote:

               

              The Get(DocumentPath) on FMGo does not refer to a path on the server. Get(DocumentPath) gets the Document Path of the local device, which is not on the server of any device running FMGo.    Your script shouldn't create a file on the server using a variable or a field because of the path you are using.  Filewin will not work on FMGo either, that is used for windows path.

              Here is a link to the Filemaker Development Guide https://www.filemaker.com/support/product/docs/filemaker-go/fmgo_development.pdf

               

              I don't fully understand that then, because I am getting a file created on the server. It's just that when I add a field to the filename, it doesn't get created.

              • 4. Re: Export single record from FM Go to FM Server w/unique filename
                wfgclapp

                Greg Lane wrote:

                 

                Each time you call a script with Perform Script on Server, the script starts with a new environment. So, the second script does not have the same found set as the previous script. I'd suggest combining your two server-side scripts or create a new server-side script that will call your two existing scripts using a regular Perform Script.

                Ah. That's good to know. I'll try that out. Thanks!

                • 5. Re: Export single record from FM Go to FM Server w/unique filename
                  schamblee

                  You not did state that you were using Perform Script on Server or I miss that In your post.   If the script is ran from the device the Get(DocumentPath) will give the document path on the local device, which will create the file on the device.

                   

                   

                  I missed it in the script the first time, sorry about that. I was zoned in on the path, because that is where most issue are when a file is not created.

                  • 6. Re: Export single record from FM Go to FM Server w/unique filename
                    schamblee

                    I would create a calculation that combines the path with the field, then view to see if the path is as expected, You may have to add a slash or trim the field to remove spaces.

                    • 7. Re: Export single record from FM Go to FM Server w/unique filename
                      wfgclapp

                      Greg Lane wrote:

                       

                      Each time you call a script with Perform Script on Server, the script starts with a new environment. So, the second script does not have the same found set as the previous script. I'd suggest combining your two server-side scripts or create a new server-side script that will call your two existing scripts using a regular Perform Script.

                       

                      Well...that didn't seem to work. Unless I combined the script wrong. New script setup below...

                       

                      • 8. Re: Export single record from FM Go to FM Server w/unique filename
                        user19752

                        $$timestamp has no value on second script when run on server.

                        • 9. Re: Export single record from FM Go to FM Server w/unique filename

                          I don't quite understand why you are using perform script on server to save a file to your own documents path, or the user's computer's document path? This script would run just fine as a simple normal script.


                          It will also work just fine to save to another computer via the network path shown below.


                          If you are trying to save it to the FileMaker Server computer you don't have the tools with FileMaker to do that. If you know the network pathname you can put together a variable to do that and again, you don't need Perform script on Server to do that.


                          All of the paths available to a FileMaker scripter are paths on the user's computer not the server. It would be unwise to provide a server path. In fact, the only info you get is the IP address, right? YOu can manually get the server's address if you have access to the server.


                          The export dialog does let you designate a remote computer to save the file if you know the pathname.

                          Export Dialog.png


                          Notice the pathnames highlighted in yellow. You must set your variable to match that and / works but \ and : do not.


                          Your $variable, not $$variable, must follow those examples and have the proper .sfx (suffix).


                          FileMaker Go will save files to its own directory as I have done with PDF reports.


                          You say that "filewin:"&Get ( DocumentsPath ) & "fmchange.txt" works but


                          "filewin:"&Get ( DocumentsPath ) & Order Edits::Sequence & "fmchange.txt" does not.


                          One problem with this is that Sequence may not create a valid file name or path name.


                          It should resolve to something like 123fmchange.txt but being a number it may not resolve correctly.


                          Try: "filewin:"&Get ( DocumentsPath ) & getastext ( Order Edits::Sequence ) & "fmchange.txt"


                          Try: "filewin:"&Get ( DocumentsPath ) & "/" & getastext ( Order Edits::Sequence ) &"/" & "fmchange.txt"

                          if sequence is to be a folder

                          • 10. Re: Export single record from FM Go to FM Server w/unique filename
                            wfgclapp

                            jackrodgers wrote:

                             

                            I don't quite understand why you are using perform script on server to save a file to your own documents path, or the user's computer's document path?

                             

                             

                            I'm not trying to save a file to the user's computer. I'm creating a file on the server (or trying to). And this is working just fine except for the filename and the content of the file.

                             

                            You say that "filewin:"&Get ( DocumentsPath ) & "fmchange.txt" works but


                            "filewin:"&Get ( DocumentsPath ) & Order Edits::Sequence & "fmchange.txt" does not.


                            One problem with this is that Sequence may not create a valid file name or path name.


                            It should resolve to something like 123fmchange.txt but being a number it may not resolve correctly.


                            Try: "filewin:"&Get ( DocumentsPath ) & getastext ( Order Edits::Sequence ) & "fmchange.txt"


                            Try: "filewin:"&Get ( DocumentsPath ) & "/" & getastext ( Order Edits::Sequence ) &"/" & "fmchange.txt"

                            if sequence is to be a folder

                             


                            Thanks for the idea but this didn't work.

                             

                             

                             

                            • 11. Re: Export single record from FM Go to FM Server w/unique filename
                              wfgclapp

                              user19752 wrote:

                               

                              $$timestamp has no value on second script when run on server.

                              Oh. I didn't realize that wouldn't carry over. I guess that explains why my 'find' isn't working.

                              • 12. Re: Export single record from FM Go to FM Server w/unique filename
                                rgordon

                                I'm guessing that sequence is a number so you are trying to save a file to an invalid file name.  A file name can not start with a number.  Try to changing your path to:

                                 

                                "filewin:"&Get ( DocumentsPath ) &"_" & Order Edits::Sequence & "fmchange.txt" or


                                "filewin:"&Get ( DocumentsPath ) &"fmchange_" & Order Edits::Sequence & ".txt"

                                • 13. Re: Export single record from FM Go to FM Server w/unique filename
                                  rgordon

                                  I think you are on the right path but if Order Edits::Sequence is a number like 123, GetasText(Order Edits::Sequence) will still return 123.


                                  • 14. Re: Export single record from FM Go to FM Server w/unique filename
                                    user19752

                                    I forgot to write that you may need "Go to Layout" at first of script on server if the layout of Order Edits table is not default.

                                    As greglane mensioned, it runs on "new environment".

                                    1 2 Previous Next