Jump to content

Recommended Posts

Not sure if this is the relevant area however, I couldn't seem to find a scripting section

What I would like to do and I have had no success so far is the following scenario.

I have database which stores references to files in container field located on a folder on a shared computer.

What I want to do is have a script which when run populates the database with the names of those files located in the folders on the computer and create a new record for those not already present and if they are already present ignore the import.

I have tried a test script which gets the documents path and loops through each record however I get file unknown when debugging and that is as far as it goes.
The script in no one handles the above scenario of omitting and inserting only new docs it was just a test to see if it was possible to import via this method. From what I can see the script is asking for a particular filename and if it can't be found it throws the error. That though is no good as essentially the filename is in a sense unknown at the time of import and that is what the purpose of the script would be i.e. too find those files and create a new record with reference only in a container.

Documentation on this is either non existent or sparse and confusing to say the least (or at least that's how I find it)

Any enlightenment would be appreciated.

 

Share this post


Link to post
Share on other sites
11 hours ago, Peter Barfield said:

I have tried a test script which gets the documents path and loops through each record however I get file unknown when debugging and that is as far as it goes.

You get that error on what part of the script?  Can you post your script?  That will help us debug.

Share this post


Link to post
Share on other sites

Wim, 

This is the script as it stands now.

Got Record/Request/Page [First]

Loop

Insert File [Reference;Never compress; Table:: Field; "".""]

Go to record/Request/Page [Next Exit; after Last]

End Loop.

I know this is not going to do what i am after it was a test to see the idea behind the step Insert File. The script goes to the first record then displays the error unknown file and i am assuming that is because it can't find the ""."" file as it isn't a true file. I realise from what docs i have read if I specified a file that exists at that directory (let's just say ABC.txt) then it would work and import it into the field.

As I have explained I am working on the basis that I have no idea what docs or how many exist in that directory and they will be updated throughout the day and the directory will be populated throughout the day with new docs. I just want to import what is in the directory into a container field for each one in filemaker a reference to them. So in other words the script if it is possible would be along the lines of

Go to the directory specified

Get the first Document

Look in the filemaker table

if they document name does not exist

create a new record and insert the reference to the doc in a container field.

If it exists skip that one and go to the next and so on - loop through all the docs in the directory until finished.

I don't even know whether this is in the scope of filemaker or not.

Hope this makes sense.

Share this post


Link to post
Share on other sites

Sure it is...

The trick is knowing what file to insert, the "insert file" script step can take a variable as the path+filename so that's covered, see example 3 in the help:

http://www.filemaker.com/help/14/fmp/en/html/scripts_ref1.35.57.html

So how do you know what files to loop through?  You can use the FM Get() functions to get a listing of a folder, or you can do a bit of OS-level scripting to get the file names in a folder or folder structure.

Once you have that input then you can loop through it and compare it against your data already in FM.

It's not clear from your description where you are stuck:

- in getting the list of files from a folder

- or comparing that input to your records

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Similar Content

    • By JH Howland
      Filemaker Pro 11 is running on two Windows 10 computers connected as Host and Client over a network.
      The script to import data from an Excel .csv file utilizes the following script step options:
          1. Un-Checked - Specify data source - File
          2. Check - Specify import order, Import Action
              a. Select - Update existing records in found set
              b. Check - Don't import first record (contains field names)
          3. Check - Perform without dialog
      When the Import script is run from the Host computer, and the desired .csv file is manually selected, the Excel first row field names are not imported and the second row with the data is imported as expected. (See Host Import Mapping)
      When the same script is run from the Client computer, the Excel first row field names are imported and not the second row data.  To get the proper result, I have to leave the check box for "Perform without dialog" unchecked and then manually, from the "Import Action" group, check the box for "Don't import first record (contains field names)" to get the proper data imported. (See Client Import Mapping, check box is no longer checked)
      Is this caused by a defect in FMP 11?  I can't figure out why this is happening.


    • By trevix
      On windows 7 (VMware on OSX), using FMP17 and Microsoft Access 2016
      Trying to do a ODBC import and selecting the datasource, I get asked for Username and password, even if the Access DB is not password protected.
      The data sources are correct (tested from Livecode) and should be working without user name and password.
      On the properties of the ODBC pane setup the path seems correct (not pointing to 32): %windir%\SysWOW64\odbcad32.exe
      What am I missing?
    • By Jhon Doe
      Hi everyone,
      I'm a beginner in FM, and i'm trying to develop a solution that allows me to import data from a csv file. I have two related tables Customer ("parent") and Alerts ("child"), each one has a primary key and the Alerts table has a foreign key to conect with the Customer table. I have to populated the alerts table from a cvs file that could have lots of records so I want to relate this new data to the right customers automatically when i import it, the new data does not have a field with the customer ID (primay key) only has its name. Could you please give me any advice with that?
    • By Pavlk
      I've attached two files. The first one is INVOICE, that is generated by every establishment when you purchase, and is in xml format.
      The second one is XSLT file, that is provided by government fiscal institution and is used to "translate" xml.
      PROBLEM DESCRIPTION: when I try to decode xml using attached xslt scheme on any online xml-converter website the output looks fine. BUT when importing to Filemaker, I receive an error: "XML parsing error: invalid document structure".
       
      I would appreciate any help with the issue. Thanks.
      XML input.xml
      XSLT scheme.xslt
    • By MSPJ
      Hi - I'm developing a business solution to be hosted on FM Server.  It will be hosted on Soliant Cloud.  This is my first time developing for Server.  I read Steven and Wim's whitepaper on FM 16 security, which was very helpful.
      In the past, when I've created upgrades to my solution, I've imported data from the previous version into the new one. Each update is a modified version of the previous file. 
      I read about the benefits of using File Access Protection. My solution is a single file solution so I can basically exclude any other file having access - except I'm not sure what impact that will have on import from previous versions.  I assume both files will have the same ID - but not sure if that means that FM will see the older version as trusted or not. 
      Thanks!
×
×
  • Create New...

Important Information

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