8 Replies Latest reply on Nov 14, 2012 1:01 PM by comment

    Pull value from file

    strngr12

      I hope this is the right forum. Anyhoo, I want to set a field's value to a string in an external text file. So, for example, if I have a file named foo and the only text in the file is"bar" in a script it I want to be able to set the value of an existing field in a Filemaker document to the text string "bar."

       

      Can someone tell me how to do that?

       

      Thanks,

       

      Dan

        • 1. Re: Pull value from file
          comment

          Try importing with the option to update existing records:

          http://www.filemaker.com/11help/html/import_export.16.11.html#1027964

          • 2. Re: Pull value from file
            strngr12

            Thanks for your answer, but I should be more clear.  There is a clip in an external database.  I have a record for the clip in Filemaker that contains information about it - lens shot with, day shot, scene, etc..., but I want to get the file ID for that clip from the external database into my filemaker database.

             

            I want the process to happen with the push of a button so that, in browse mode, someone can be in a clip record and push a button - say, "Get ID" - and a script runs that feeds a command to the shell through apple script that will pull a metadata xml file from the exteranal database and I can just use grep and sed to strip everything out of that file and leave only the file ID.

             

            That's where I'm stuck.  I have the button, it runs the script, it leaves me with a file that has the ID I'm looking for but, right now, I'd have to open that file, look at the ID and type it into Filemaker.  Is there a way to just pull that string and put it in the File ID string with no dialogue to end the script?  I'd like someone to be able to just push the button and have all that happen in teh background and then, a few seconds later, the ID is in the field.

             

            Any ideas?

             

            Thanks,

             

            Dan

            • 3. Re: Pull value from file
              comment

              What type is the external database? Perhaps you could communicate with it directly via ODBC?

               

              In any case, if you are already running AppleScript, why go through the file at all? Have the AppleScript read the value and pass it back to Filemaker.

               

              Finally, even with the file, assuming that you know the file's name and path, you can import it as part of your current script.

              • 4. Re: Pull value from file
                NewFM_Dev

                Hi Strnger, Have you checked out the possibilities with the 'setfield' functions?

                You can set fields from internal OR external db's.

                -Newbee

                • 5. Re: Pull value from file
                  strngr12

                  There is one more thing I should add.  This is being written for distribution to people who have Filemaker databases and are interacting with this 3rd party database.  It will need to be implemented in many different Filemaker databases.  Thus, the push button approach.  The 3rd party database is a proprietary, secure media distribution platform that has a CLI that allows you to pull metadata on the files it holds in XML format.  Thus, the push button approach.  I want to be able to construct a script that I can import into client databases that will pull the ID out of that metadata XML.

                   

                  What type is the external database? Perhaps you could communicate with it directly via ODBC?

                   

                  Tried that, but the 3rd party is ultra secure and will only allow interactions with it's database through means approved by independent audits from it's clients.  Basically, you can watch and interact your clips and media through their GUI apps and import and export metadata through their CLI and API, but they have a contractual obligation not to allow other software to interact with their database in any way - including ODBC and Filemaker.

                   

                  I can use Applescript because I just use it to create calls using the 3rd party's CLI through Terminal.  It's fine, because I have gotten scripts that take all the metadata out of Filemaker and put it into the 3rd party database, and I can make a call to get all the metadata out of the 3rd party database and onto my computer, but that last step of getting the metadata I have pulled into Filemaker is where I'm stuck.

                   

                  In any case, if you are already running AppleScript, why go through the file at all? Have the AppleScript read the value and pass it back to Filemaker.

                  This would be great.  Right now I just store the output in a file because that's all I know how to do.  The 3rd party CLI drops an xml file with the metadata you have requested where ever you want and I can then just isolate the one piece I am alook for using greap and sed, but I just don't know how to go further.  I'm not an Applescript guy.  If you could point me in teh right direction with Applescript that would be awesome!

                  Finally, even with the file, assuming that you know the file's name and path, you can import it as part of your current script.

                  This is what I'm asking how to do.  If I have the name and path, how do I import it?  To be clear, I don't wan to import the file as a container unless that is a necessary step in pulling the string from it and storing it in a text field.

                   

                  Thanks so much!

                   

                  Dan

                  • 6. Re: Pull value from file
                    comment

                    strngr12 wrote:

                     

                    Finally, even with the file, assuming that you know the file's name and path, you can import it as part of your current script.

                    This is what I'm asking how to do.  If I have the name and path, how do I import it? 

                     

                    You import it as a text file. Assuming it does not contain any tabs or returns, and you import it as tab-separated text, all the text will go into a single field. But it's really taking the scenic route.

                     

                     

                    strngr12 wrote:

                     

                    I'm not an Applescript guy.  If you could point me in teh right direction with Applescript that would be awesome!

                     

                    Try something like:

                     

                    set myValue to ...

                    tell application "FileMaker Pro"

                    set cell "MyField" of current record of layout "MyLayout" of document "MyDB" to myValue

                    end tell

                     

                    Of course, if you're running the AS from within Filemaker, the tell is unnecessary.

                     

                     

                    strngr12 wrote:

                     

                    I want to be able to construct a script that I can import into client databases that will pull the ID out of that metadata XML.

                     

                    Couldn't you  import the XML directly? Filemaker can request XML from a HTTP source and import the result, using a custom XSLT stylesheet. Seems like that would be the machine with the least moving parts.

                    1 of 1 people found this helpful
                    • 7. Re: Pull value from file
                      strngr12

                      Thanks again for your answer.  A couple questions.  Sorry, but I need a little more hand holding.  First, what command would I use in Filemaker to import an external text file into a field in a record the script is currently in?  I know how to import a text file as a new record, but I need this imported to a field in an existing record.

                       

                      Also, if I run an Applescript from Filemaker that ends with a shell command to, say, echo 1234567 what would I use to capture that echo so I can set MyField in the current record to 1234567?

                       

                      I can't get teh XML directly because the 3rd party DB doesn't accept calls from anothing other than it's own GUI and CLI apps and, aslo, operates only on https.

                       

                      I appreciate the help.

                       

                      Thanks,

                       

                      Dan

                      • 8. Re: Pull value from file
                        comment

                        strngr12 wrote:

                         

                        First, what command would I use in Filemaker to import an external text file into a field in a record the script is currently in? 

                         

                        You would isolate the current record so that it's it the only one in the found set, Then import using the option to update existing records.

                         

                         

                        strngr12 wrote:

                         

                        what would I use to capture that echo so I can set MyField in the current record to 1234567?

                         

                        You could do:

                         

                        set myValue to do shell script "echo 1234567"

                         

                        then continue as described above.