August 4, 200619 yr 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, 200619 yr by Guest
August 4, 200619 yr ...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
August 4, 200619 yr Author 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.
August 4, 200619 yr 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?
August 4, 200619 yr Author Yes, comparing the set of records imported to the already existing records. Edited August 4, 200619 yr by Guest
August 4, 200619 yr 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
August 4, 200619 yr 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.
Create an account or sign in to comment