Jump to content
Server Maintenance This Week. ×

What is best practice for scripted Imports?


This topic is 1559 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Screen Shot 2020-01-23 at 12.39.59 PM.png

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 1559 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.