Can you provide an explanation of how to import records using a script with no dialog box?
Also, are there any useful plugins to the FileMaker 17 Advanced platform? (e.g. for quering directory contents,...).
Please describe what you want to do in more detail.
It is possible to use Insert File to get the file path to a file selected by the user for import.
A script can then validate file type or possibly file name and import records. The dialog to select the file would be the only one that the user sees.
It's also possible for this to be done by always importing records from a specific directory through use of a plug in used to read the contents of the file. You can dispense with the plug in if the file always has the same name such as a situation where you periodically replace the file with a new copy and then the script imports.
So it depends on what you have in mind.
Every month I download from my bank the statements from my creditcards and bank accounts, placing them in a certain folder according to date (say Downloads/Oct 3 2018). I need a script that imports these statements into tables, credit cards into credit card table and bank accounts into bank accounts table. But I do not want the user to choose which are the files to import. The program must deduce the folder name from the date as given by the user. The date can be chosen by using a calendar control,for instance.
Also, I need the script to detect if the file is a credit card statement or a bank account statement and to choose the appropriate target data table. How can I do this?
Are there no raw functions for reading a CSV files in order to detect which kind of statement it is? like fopen() in C?
There is no such built in function.
First thing your script would need to do is read the files in a folder. If you locate your folder inside the documents folder, filemaker can use the get ( documentsPathListing ) function to read the file names.
Otherwise, you’d need to use either a system script or a plug in to get that list of files.
If the file name can be used to distinguish between statements, your script can use different import records steps to import into different tables.
If you have to examine data in the file to tell the account, you’ll need to import the data first. You might use import twice, once into a staging table and then into the now identified table. You might also import both sets of transactions and use scripts/relationships to segregate your data by account when needed.
How can I use the Get(DocumentsPathListing) return value to access each file returned? The files are separated by a white space...
You get a return separated list of file paths for every file and sub directory in Documents. You have to then parse the filenames from that list. The files located in your folder of files to import will all start with the same text: the file path to the folder that contains them.
You can import records programmatically using a little Java and the free FMP JDBC driver. There are tons of online examples and I've even written a quick tutorial right here on the forum. The JDBC approach is free. No Plug-in. It's fast. It uses SQL. Super cool.
You could even schedule the JDBC code to run anytime you want, say for recurring imports, via Windows or Mac scheduling facilities. Or, you could kick off the import on demand right from FMP. The Java approach will work with regular FMP or with FMS.
The JDBC approach works with regular FMP fields and container fields, too.
Below is the link to the quick tutorial I wrote:
Writing JDBC Code To Interact with FileMaker
FMI also publishes a JDBC reference I mention in the document above.
And, check out their SQL guide, too:
Retrieving data ...