Saj0916 Posted August 4, 2006 Posted August 4, 2006 (edited) My goal of this script is to import records, then run a loop that checks the existing records to see if the "Serial No." matches a duplicate record. If there is a duplicate I would like a custom dialog to come up saying "Please check File for duplicates" and exit the script. If there aren't duplicates I'd just like the script allow an import. I am a bit new to the ScriptMaker processes, and I tried using a loop with an if else but didn't have any success. Any help would be greatly appreciated. Edited August 4, 2006 by Guest
Genx Posted August 4, 2006 Posted August 4, 2006 ...strange request, but never the less. Sort Records by your serial number field then.. Go To Record[First] Set Variable[$current ; serialNo] Loop Go To Record[Next ; Exit After Last] If[serialNo = $current] Show Custom Dialog[Error ; Duplicates exist] Close File End If Set Variable[$current ; serialNo] End Loop
Saj0916 Posted August 4, 2006 Author Posted August 4, 2006 Yea sorry I miss worded my statement. Thanks for the help and I meant to say I only wanted to to import the records if there aren't any duplicates. I couldn't figure out how to include the "Import Records" portion and cancel the process if there is a duplicate. I am just trying to eliminate users importing multiple of the same records. Thanks.
Genx Posted August 4, 2006 Posted August 4, 2006 So you wan tto check if there are any duplicate records in the set you want to import compared to the set that already exists?
Saj0916 Posted August 4, 2006 Author Posted August 4, 2006 (edited) Yes, comparing the set of records imported to the already existing records. Edited August 4, 2006 by Guest
Genx Posted August 4, 2006 Posted August 4, 2006 Okkkayyyy. Then, um. Scenario being... We've imported the records, if there are any duplicates, we remove all the imported records and "fail" the import - reverting all changes. In that case we have imported the records and added one additional field to mark them as "imported". So add one additional field, call it imported - then when you import your new records, run a loop through them and set the imported field to 1. i.e. Loop Set Field [imported = 1] Go To Record[exit after last ; next] End Loop Then... Show All Records Sort[Just sort by serial No Here] Go To Record[First] Set Variable[$current ; serialNo] Loop Go To Record[Next ; Exit After Last] If[serialNo = $current] Enter Find Mode[] Set Field[imported ; 1] Perform Find[] If[Get(LastError) = 0] Delete Records[The delete all records option (will only delete foundset] End If Show Custom Dialog[Title: Error ; Message: Your import failed, there were duplicates. All imported records have been removed. Buttons: Ok , Quit] If[Get(LastMessageChoice) = 1 //If Ok Button Pressed] Exit Script Else Close File End If End If Set Variable[$current ; serialNo] End Loop Half the stuff in there is just to show you how to use some of the features. But... yes i hope this helps. As always, never work with your real data when debugging scripts like this - unless you know what your doing, and sometimes not even then. Make a copy of your file and play with that to your hearts content. Good luck ~Genx
Saj0916 Posted August 4, 2006 Author Posted August 4, 2006 Thank you very much I am about to go mess around with it
Genx Posted August 4, 2006 Posted August 4, 2006 Oh right, btw... At the end - if there arent any duplicates, make sure you find the records marked "1" for imported and then unmark them all so they arent affected when the next import happens.
Recommended Posts
This topic is 6688 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