14 Replies Latest reply on Jun 27, 2015 10:37 AM by JFWX5

    Changing Old Pass Globals to another file to Pass Variables to another file

    JFWX5

      Hi,

       

       

      I've been working on my older scripts and would like to get rid of many from 2012 which passed globals around.

       

      In in the Funeral file I have 3 fields I wish to pass

       

      Funeral::UniqueID

       

      Funeral::First Name

       

      Funeral::Last Name

       

      Over to the ScanDoc File

       

      When I pass the variable from Funeral to ScanDoc I also wish to create a relationship based upon UniqueIDs

       

      Is what I'm doing possible? And if so how?

       

      Thank you

        • 1. Re: Changing Old Pass Globals to another file to Pass Variables to another file
          Extensitech

          To pass the variable:

           

          Create a script in your target file. We'll call it "SetVariable". It takes two parameters, name and value, which we'll put in local variables $nam and $val, respectively.

           

          In SetVariable, set a variable (I just call it $result) to the following value:

           

          Evaluate (

           

           

          "Let (" &

          $nam & "[" & $num & "] = \"" & Substitute ( $val ; [ ¶ ; "\¶" ] ; [ "\"" ; "\\\"" ] ) & "\" ;" &

          "\"\"" &

          ")"

           

           

          )

           

          As for the relationship, either set a global to $uniqueID, or create a calculation field (unstored!) that is equal to $uniqueID.

           

          HTH

           

          Chris Cain

          Extensitech

          • 2. Re: Changing Old Pass Globals to another file to Pass Variables to another file
            Stephen Huston

            It sounds like you have a multi-file system which was probably started back before FM version 7 and never restructured with the data from multiple tables within a single file. While restructuring would eliminate the need to pass values between files, it is possible to pass multiple values when calling an external-file's script, by setting the "Script Parameter" where the script is called.

            example Script Parameter:

                 Funeral::UniqueID & "¶" & Funeral::First Name & "¶" & Funeral::Last Name

             

            In the receiving/called script, add initial step(s) that parse(s) out each value of the Script Parameter into a separate variable so they can be used individually where needed in that script.

            (see FM Help: MiddleValues function re parsing by calculation)

            • 3. Re: Changing Old Pass Globals to another file to Pass Variables to another file
              erolst

              I find that during debugging, this form

               

              Let (

                expression =

                "Let (" & $nam & "[" & $num & "] = \""

                &

                Substitute (

                  $val ;

                  [ ¶ ; "\¶" ] ;

                  [ "\"" ; "\\\"" ]

                )

                &

                "\" ;" \"\"" )"

                ) ;

                expression // inspect before passing it on to Evaluate ( expression )

              )

               

              is definitely helpful

              • 4. Re: Changing Old Pass Globals to another file to Pass Variables to another file
                JFWX5

                Steve,

                 

                It was started with FM 3. 

                 

                I currently have about 15K Files dealing with Funeral/Cremation(s), we have handled since the early 1900's  What I'm planning to do is scan all of our paper files into a FM document field and attach them to the each decadent's electronic file.  I'm running out of space to store all of this paper.

                 

                I know I can create multiple tables with in one file, saving me from passing around variables and globals. 

                 

                But with a average of about 50 documents per file that would run up to about 750K documents attached to the files.  Will FileMaker Server 14 handle it all in one file or should I plan to use two files?

                 

                Thank you

                • 5. Re: Changing Old Pass Globals to another file to Pass Variables to another file
                  Vyke

                  It's not about how many files, though FMS can easily handle that quantity, it's really about sizes and that is limited only by disk space.

                   

                  Now, my would be to scan the files as you say, and instead of uploading them into container fields, store the files on a drive on the server and store only a reference to the files in the container. This will help you keep the files organized and will not bloat the FileMaker file size.

                  • 6. Re: Changing Old Pass Globals to another file to Pass Variables to another file
                    Extensitech

                    If you use external storage (introduced in FM13), your containers will store the documents in a folder on the server, rather than in the FM file itself.

                     

                    Chris Cain

                    Extensitech

                    • 7. Re: Changing Old Pass Globals to another file to Pass Variables to another file
                      JFWX5

                      OK,

                       

                      I've decided I'm going to use FMS14 with containers as "store container data externally" with secure storage

                       

                      With the following FM calculated AppleScript

                       

                      "do shell script  \"/usr/bin/fscanx --pdf /scandata/" & Funeral::Last Name & "_Document Title" & "\""

                       

                      What would be the next command in this script be in order for Filemaker to insert the file "Last Name_Document Title.pdf"

                       

                      into a container named Funeral::Document?

                       

                      Thank you

                      • 8. Re: Changing Old Pass Globals to another file to Pass Variables to another file
                        Extensitech

                        Not sure where you're going with this. I do this all the time without applescript. Set a variable for $pth. Save a pdf to that path. Insert file from that path into the container...

                         

                        The container is set to use external storage, and the file gets stored in a folder on the server.

                         

                        Am I missing something, though? Are you trying to do something more?

                         

                        Chris Cain

                        Extensitech

                        • 9. Re: Changing Old Pass Globals to another file to Pass Variables to another file
                          Stephen Huston

                          I've decided I'm going to use FMS14 with containers as "store container data externally" with secure storage

                           

                          If you use Secure Storage on the Server, which is how it was intended when originally designed, then the Server takes care of placing your documents into the storage location. I also see no reason for AppleScript in this process based on your descriptions so far.

                          • 10. Re: Changing Old Pass Globals to another file to Pass Variables to another file
                            electon

                            JFWX5 wrote:

                             

                            OK,

                             

                            I've decided I'm going to use FMS14 with containers as "store container data externally" with secure storage

                             

                            With the following FM calculated AppleScript

                             

                            "do shell script  \"/usr/bin/fscanx --pdf /scandata/" & Funeral::Last Name & "_Document Title" & "\""

                             

                            What would be the next command in this script be in order for Filemaker to insert the file "Last Name_Document Title.pdf"

                             

                            into a container named Funeral::Document?

                             

                            Thank you

                            You can applescript filemaker same way you do with other scriptable apps.

                            But it can get complicated, you need to wait for the pdf to be actually generated etc. etc.

                             

                            If this is just to archive the old documents:

                            What I would do is make it a two-pass operation.

                            I would make the pdf storage into a separate table. with foreign key to the Funeral::UniqueID.

                             

                            First from filemaker use your applescript to scan the docs for every record you need into the same folder, prepending the filename by the unique ID, optionally with a separator character that won't mess with allowed file name characters.

                            After scanning everything, import all the pdfs to the documents table in one go, from the folder.

                            Post-process this in this way:

                            You could devise a calculation that separates out the UniqueID from the container file name.

                            GetContainerAttribute ( table::containerField ; "filename" ), look for your separator there and you will know which part of it is the ID.

                            If your calc works then you could use Replace Field Contents and your calc on the foreign key field.

                             

                            After that all your pdf's will match to the parent record.

                            EDIT: Be ware of doing this on a live system, test first and make sure there are no other documents in the table prior to that.

                            Maybe create a solution just for that and figure out later how to transport the data to the live solution.

                            • 11. Re: Changing Old Pass Globals to another file to Pass Variables to another file
                              beverly

                              no need to pass globals or variables, if you create the relationship and 'allow creation of related records'. You can then set field (to the Scan Docs) with the fields in Funeral. Or you could even have these "auto-enter" based on the relationship.

                               

                              It sounds like you are putting mutiple documents in related one to many (Funeral--<Scan Docs), the related (allow creation) and auto-enter would allow you to post the documents in a portal (albeit larger to hold a conatiner). Each posted document creates a new record thru the relationship.

                               

                              Is that what you want?

                              beverly

                              • 12. Re: Changing Old Pass Globals to another file to Pass Variables to another file
                                JFWX5

                                Hi,

                                 

                                It's one Funeral to many documents.  When the user selects a decedent in funeral, then clicks a button, all of that decedents scanned records appear in a new window for the user to scroll thru.

                                 

                                I go into Mr. Smith's file in Funeral and then

                                 

                                run a FM script containing a calculated AppleScript step

                                 

                                "do shell script  \"/usr/bin/fscanx --pdf /scandata/" & Funeral::Last Name & "_Document Title" & "\""

                                 

                                Which drops a pdf File called i.e. Smith_Death Certificate into the /scandata folder if the decedent's name = Smith and _Document Title= Death Certificate

                                 

                                My problem is the calculation to insert the file into the container filed, I could setup the FM script to insert "Smith_Death Certificate".pdf

                                 

                                but how do I setup the calculation if the next time I need to insert Smith_ME Cremation Permit.pdf

                                 

                                or I'm in another clients record and and I want to insert Jones_Embalming Report?

                                 

                                Thank you

                                • 13. Re: Changing Old Pass Globals to another file to Pass Variables to another file
                                  electon

                                  Store the Unique Id in a variable.

                                  $UniqueID = Funeral::UniqueID

                                   

                                  First, you need to define the Folder containing the scans.

                                  Set Variable ( $fscanx = "pdf/scandata/" )

                                   

                                  Then the path that filemaker will understand:

                                  Set Variable ( $folder = "/Macintosh HD/ & $fscanx )


                                  Then the file name:

                                   

                                  Set Variable ( $fileName = Funeral::Last Name & "_Document Title.pdf"  )


                                  Your apple script will look like this:

                                  "do shell script  \"/usr/bin/fscanx --" & $fscanx & $fileName & "\""


                                  When the file is created you construct the filemaker path to file:

                                  This bit is important === If you don't set your container field to interactive mode

                                  IT WILL FAIL!!!

                                   

                                  The thing is that for inserting pdf's via the Insert Pdf script step on OSX you need to use imagemac not file or fiemac.

                                   

                                  Set Variable ( $path = "imagemac:" & $folder & $fileName )

                                  This will construct the path to your pdf based on previous parameters.

                                   

                                  Then

                                  Go To Layout ( where the pdf's are )

                                  New Record

                                  Set Field ( foreign key : $UniqueID )

                                  Go To Field ( the container field )

                                  Insert Pdf ( $path )

                                   

                                  and the rest as usual...

                                   

                                   

                                  Do I have to do everything myself?

                                   

                                  • 14. Re: Changing Old Pass Globals to another file to Pass Variables to another file
                                    JFWX5

                                    Electon,

                                     

                                     

                                    This was what I was trying to figure out.  I'll test and report back.

                                     

                                    Thank you,

                                     

                                     

                                    John