Jump to content

Duplicate record script help


This topic is 5598 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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 by Guest
Link to comment
Share on other sites

...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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 5598 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

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