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

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

  • Similar Content

    • 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!
    • By kolvorok
      I'd get some problems with date formats after installing FMS 15, and I'm trying to solve it by importing to a clone of the original database. But two tables has no layouts and I can't find a way to import these tables without making a layout in the clone or adding a table when importing. The last seems to be the simplest, but how will the relationships behave?
    • By Jeff M
      Hello,
      I've done quite a bit with FileMaker in the past, but have never jumped into the XML arena. Now I have a need to do so, and I'm really needing some help with something I'm sure is quite basic...but still foreign to me. I have an external data source which export XML in a very specific format (see attached). I need to import that into FileMaker so I can manipulate the data, do some various lookups, etc. Once I've made my changes in the data, I need to export in the exact format it was when imported so the external data source can properly import.
      Not sure if it makes sense to import into 2 tables (workflows, workflow steps) or just a single table. I'm open either way. Once the data is in FileMaker I can get all my calculations and lookups and scripts going and make the data what I need it to be, but then I'll need to export it.
      Can someone point me in the right direction?
      Thanks so much in advance!
      Jeff
      workflows_export.xml
  • Who Viewed the Topic

    10 members have viewed this topic:
    fmdataweb  MSPJ  Johnn  siroos12  lauren@paradisepartners  dennis_em  Carson  mattp52  Jonathan Ackerman  Bagi 
×

Important Information

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