May 7, 20214 yr I have a solution that imports xml files throughout the day . The way its set up is when a xml file gets dropped into a networked folder titled with its Job No ( 90001.xml, 90002.xml, 90003.xml ) an AppleScript is triggered and moves the XML file to a new folder and renames it to ImportXML.xml. The AppleScript then triggers a FM script that imports the xml into a solution and then then AppleScript deletes the .xml file. What I would like is Filemaker to be able to import using the original job number ( ****.xml ) and loop through everything that’s in the folder and to delete once imported. Any ideas if this is possible in Filemaker or maybe a 3rd party plugin.
May 7, 20214 yr Filemaker cannot see what files are in a folder if the folder isn't in the Documents folder. I believe that alone rules out a 100% native solution in your case. Filemaker will also not "watch" a folder for added files (though it can run on a schedule). What is the problem you are trying to solve here? You seem to have a working solution using AppleScript; what advantage would be gained by using a plugin instead? -- P.S Please update your profile to reflect your version and OS so that we know what you can use.
May 7, 20214 yr Author Hi comment I've noticed that my current solution doesn't always run and errors out every now and then. I have hundreds of files being moved and renamed daily and this part gets done on a windows shared volume. I was hoping that I could just have the files saved in one folder that triggers a script that imports the current contents of a folder no matter of its name.
May 12, 20214 yr Hey there, This is a bit of a crude solution that was provided to me from a friend, but it might be able to be adapted for what you're trying to do. It requires the (free) Base Elements plugin, and is currently used on a Windows file - I imagine you could alter it accordingly to work on Mac. The script gets a list of the files in the Import directory If there are no files, the script exits If there are any files, it loops through each file It attempts to import the file using the specified XSLT file If successful: It moves/renames the file to the completed directory (renames file to: (Original Filename).xml.(date & time) -- e.g. PO-262439.xml.20210511_134926 If an error is encountered: It moves/renames the file to the failed directory (with the same date/time format as above) The loop continues until all of the files in the directory have been processed I haven't checked, but I believe you could set this up to PSOS, or do a scheduled script to run on a regular basis (e.g. every 5 or 10 minutes). XML Import Sample.fmp12
May 13, 20214 yr On 5/7/2021 at 4:24 PM, Plucky said: I was hoping that I could just have the files saved in one folder that triggers a script that imports the current contents of a folder no matter of its name. Personally I prefer to load this type of files with XSLTPROC and CWP using cURL on the command line. For me one such line may look like xsltproc /opt/local/integration/integrationnumber/pendingstock2cURLpayloadForCWP.xslt \ | curl -XPOST http://filemaker.server.lan:80/-new -d - && mv {} done triggered by crontab or chokidar( https://www.npmjs.com/package/chokidar ) using BASh's && to mv file upon success. Some basic BASh: "A ; B" Run A and then B, regardless of success of A "A && B" Run B if A succeeded "A || B" Run B if A failed "A &" Run A in background. It's also possible to use chokidar to trigger a script in FileMaker Server using CWP based on changes in the folder. curl -XPOST -kL http://filemaker.server.lan?-script=loadFileFromFolderUsingXMLImport In order to have some sort of validation it could be desirable to do a `-new` with the filename to produce some logic on what to do next `mv {} done/` or `mv {} error/` as pr example, depending on the success rate of the parser. Edited May 13, 20214 yr by ggt667
Create an account or sign in to comment