4 Replies Latest reply on Mar 8, 2016 12:55 PM by tays01s

    Import: when the file isn't there


      I have an import script, works fine but stumbles if the user has forgotten to put a file to import into the import folder. I'd thought an

      If( not isempty (filepath/file); import script) end if

      might work but doesn't. How do I check for a file's existance in order to avoid running the import script when there is no file?

        • 1. Re: Import: when the file isn't there

          Have you tried to catch the last error? I'm not sure what it should give you as feedback, but it should be one.

          Try to set $error   to  get(lasterror)

          if $error = 0 run remainder of script.

          • 2. Re: Import: when the file isn't there

            Thank you; good idea that works.


            1 problem that remains is that I have export files from 8 tables to be imported as 8 files. However, sometimes users will have a parent record and records from 1-7 child tables. So if there were anything less than the full 8 I'd get an error because 'import' would try to import a non-existent table.


            Possible solution: I force export to export 1 parent with a full set of child exports. I'm not sure if there's a neater method.

            • 3. Re: Import: when the file isn't there

              Hi Tays,


              You might try a loop and 'validation' check. Something like:



              if (isvalid....)     [or some other check]

                 ScriptAction  [import action]

              End If

              End loop


              For a more detailed solution I need more insight

              • 4. Re: Import: when the file isn't there

                I can see the need to validate. However, if all the import script has to validate is whether there is a particular file in a folder, how does one validate that? Out of the 8 potential files in the folder, if 2 are missing, the script is fine giving the custom dialogue warning that they are missing. The other 6 may be missing because there weren't any records to export for those tables or the user forgot to put them into the import folder. There is nothing I can do about the latter. So, I'd like the script to warn if files for tables 1+2 are missing, but for 3-8 check if they are there, if there are, import, if not, skip to the next without any warning if they are missing.


                Does that make sense?