Cabinetman Posted August 16, 2008 Posted August 16, 2008 :bang: Maybe this should be under scripts.... not sure. But here I am again! Is there a code or anything that I can use to exit a script when the import record count=0 1.I'm using "update matching" during import 2.This import file has no matching records (which can't be known until after I import) I worked around this before but don't think I can this time. I'm importing page after page and can't sit to watch the record import count. Someone please help! My brain is fried !!
Fenton Posted August 16, 2008 Posted August 16, 2008 Importing from what? If it's a FileMaker file, then there would be a way to test for Matching Records. But, I can't really see that it would be much different or faster. Are you matching against all records, or a found set? Are you importing (updating) ONLY matching records, ie., is the Add new records option turned off? It sounds like it is. There is an error code: 729 Errors occurred during import. Records could not be imported
Cabinetman Posted August 16, 2008 Author Posted August 16, 2008 Importing from what? [color:red]a .txt tab delim. file Are you matching against all records, or a found set? [color:red]all records Are you importing (updating) ONLY matching records, ie., is the Add new records option turned off? It sounds like it is. [color:red]Update matching and yes "Add new records" is turned off There is an error code: 729 Errors occurred during import. Records could not be imported I get a "0" error code..... no errors seem to be occuring. There just aren't any matching for it to update. I wasn't sure which forum this fit best but it's part of a script... In a nut shell I'm: Importing a .txt (tab delim) file to update a few fields, taking those found/matched records from this import and running a script marking them as edited. Then going to the next file and importing....so on and so on. There are at times 50 - 75 files and I can't watch the import of each one to make sure it has at least some matching records before going to the next script step of marking them as edited. So now if no records match it shows all records after import and marks ALL as edited.... ugh.
comment Posted August 17, 2008 Posted August 17, 2008 If no records match, you should get a found set of zero following the import. If it shows all (or any) records, then these records were matched and updated. It's possible that they were "updated" with the same values they had before the import - but they were updated (including modification timestamp, if you turn auto-enter on).
Cabinetman Posted August 17, 2008 Author Posted August 17, 2008 The found set IS "0" as I stated. There are NO matching records being updated. I know this to be the case. i use "Preform without dialog" so at this point it goes to basically "show all" records so that my script continues and EVERY record gets marked as "updated" I need to find something generated by this "0" found records to use to exit the script!
comment Posted August 17, 2008 Posted August 17, 2008 I don't follow. Why don't you mark records as 'updated' immediately after the import - so that if the found set is 0, no records are marked?
Lee Smith Posted August 17, 2008 Posted August 17, 2008 How would FileMaker know that there are no records to be update until it has looked at all of the records in the found set, and then completed the script?
David Jondreau Posted August 17, 2008 Posted August 17, 2008 Ermmm...have you tried putting this immediately after the Import[]? If[Get(FoundCount) = 0] Exit Script End If
Cabinetman Posted August 17, 2008 Author Posted August 17, 2008 First thanks to everyone for trying... really. But it was as simple as..... Import records If[Get(FoundCount) = 0] Exit Script End If .....Worked just fine! Sorry some weren't getting this or realizing what was happening but to answer a few: I don't follow. Why don't you mark records as 'updated' immediately after the import - so that if the found set is 0, no records are marked? That's exactly how it was set up but because immediately following the import if there were no errors and no records matched to update it "shows all" like I said before and then proceeds to mark all as updated. How would FileMaker know that there are no records to be update until it has looked at all of the records in the found set, and then completed the script? "...and then completed the script?" ? Not sure why it would need to complete the script but thanks anyway......... I expected that FileMaker would know right after the import that no records were updated since if you uncheck the "preform without dialog" and watch step by step you get the display.... Import records summary: Total records added/updated: 0 Total records skipped due to errors:0 Total records fields skipped due to errors: 0 Table created: and get an error code of : 0 Anyway........ I have what I needed and thanks !!
Vaughan Posted August 17, 2008 Posted August 17, 2008 "I expected that FileMaker would know right after the import that no records were updated..." FileMaker *does* know... the challenge is to program your script so that it recognises the condition and can behave accordingly. :(
Cabinetman Posted August 18, 2008 Author Posted August 18, 2008 I figured, but I just couldn't see what I needed to do........ Maybe I should have put this in scripts so that it was more obvious what I needed
Vaughan Posted August 18, 2008 Posted August 18, 2008 Whenever you're doing a process that needs to work with a found set of records, think about what would happen if 1) the whole database is selected; or 2) no records are selected. Script accordingly. Usually these checks should be done after a find, an import, or before an export or a looping script that processes a found set of records. Even if there is "no way" the found set could be empty (or whatever). I once worked on a solution (not originally done by me) where a process failed in the most obscure manner because there was an empty found set where it was impossible to have one. What had happened was the data had been recently imported but the primary key hadn't been set! A quick and simple check for IsEmpty( relationship::primarykey ) in the process would have spotted it but the original developer considered such defensive programming techniques as a waste of time and unnecessary. It took many hours to debug and fix. ;(
Cabinetman Posted August 18, 2008 Author Posted August 18, 2008 Good point! It'll make me go through everything again to check my scripting for potential problems ! But hey considering that I build cabinets for a living and have no programing type training at all it's understandable that I missed something like that....
Vaughan Posted August 18, 2008 Posted August 18, 2008 "ut hey considering that I build cabinets for a living and have no programing type training at all it's understandable that I missed something like that...." Yes... but it's like me building something out of wood (expensive wood, at that) and not taking into account the fact that wood changes with humidity; I end up making something that will, in time expand, warp or self-destruct. ;(
Recommended Posts
This topic is 5941 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 accountSign in
Already have an account? Sign in here.
Sign In Now