January 23, 20205 yr I have searched the forum and internet and not found an answer to my delima. I have a solution with a scripted import of a csv file. I do not want import dialog (e.g. mapping), so I have it set to no. I don't know the name of the file, only that it is a csv file. If I leave the filename out of the import dialogue, the default SHOW filetype in the open file dialog is for a filemaker database. The user needs education to change the SHOW to csv or all. That is undesirable. If I import a correct file once, the next time the script runs in that session, it prompts for a csv file, but if I quit the application and run it again, it goes back to SHOWing filemaker databases. If I provide a bogus file, e.g. YourFile.csv -- I have to capture errors or I get no file dialog for them to find their file. If they cancel, they get a filemaker dialog I don't control that tells them the user aborted the import, continue or cancel. If they cancel, the script exits and I don't get control. That, too, is undesirable. What is the best practice for scripted imports so that whether the user complies or cancels, I maintain control of what happens next?
January 23, 20205 yr A classic approach here is to use a global container field and use the "insert file" script step to let the user select the file they want to import. Your script then turns around and uses "export field content" to spit the file back out but renamed to a static known name that you use in the import script step file reference. As to the cancel: you'd trap for that on the "insert file" script step.
January 23, 20205 yr Author Thanks, I understand and like it. However, I have tried about every possible option and cannot get Insert File to prompt for the file. Is there a trick? I've had no special dialog and the one enclosed. I've tried no source and a bogus source and an existing source. I've tried "go to field" and specified my field as a target. I always get error 102. Googling around, I discovered there is a bug in FMP16A -- even though I have FULL ACCESS, I have to give the script FULL ACCESS. Thanks.
January 23, 20205 yr Author Frustrated. In a quicky test database, Insert File works fine from a script with Full Access privileges. I put the exact same line into my application and I get error 102. I've tried about everything. As soon as I give up, I find the solution. The container field has to be on the layout. All is well.
Create an account or sign in to comment