Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Idea to prevent duplicates help please


RichGags
 Share

Recommended Posts

Im trying to prevent duplicate clients. I had an idea to check whether or not a phone number has been entered already in the system. I created a script trigger on the phone number field to check if the number exists in the client DB and give the user a chance to view the existing record or overide and continue entering. It works great except for one thing... Ive got "Save Record Changes Automatically" unchecked on this layout. So when I try to close the window, go back to the first window and enter find mode in choice 1 (below) The user has to press "Dont Save" in order to cancel the new entry and go to the existing record. How can I circumvent this? or Should I be going about this a completely different way? Thanks!

 

Allow User Abort [ Off ] 
Set Variable [ $CurrentWindow; Value:Get(WindowName) ] 
Set Variable [ $NewClient_ID; Value:Client::Client Number ] 
Set Error Capture [ On ] 
Set Variable [ $Phone_To_Check; Value:Client::Cell Phone ] 
New Window [ Name: "Duplicate Client" ] 
Go to Layout [ “Clients & Events” (Client) ] 
Enter Find Mode [ ] 
Set Field [ Client::All_Phones; $Phone_To_Check ] 
Perform Find [ ] 
If [ Get(FoundCount)=0 ] 
Exit Script [ ] 
Else 
Show Custom Dialog [ Title: "Oops!"; Message: "It appears this client or phone number is already entered in the Database. Do still want to enter a new client, or go to this client's existing file?"; Buttons: “Existing”, “New”, “View Dup” ] 
If [ Get(LastMessageChoice)=2 ] 
Close Window [ Name: "Duplicate Client"; Current file ] 
Commit Records/Requests [ No dialog ] 
Enter Find Mode [ ] 
Set Field [ Client::Client Number; $NewClient_ID ] 
Perform Find [ ] 
Exit Script [ ] 
Else If [ Get(LastMessageChoice)=1 ] 
Set Variable [ $Client_ID; Value:Client::Client Number ] 
Close Window [ Name: "Duplicate Client"; Current file ] 
Select Window [ Name: $CurrentWindow; Current file ] 
Enter Find Mode [ ] 
Set Field [ Client::Client Number; $Client_ID ] 
Perform Find [ ] 
Exit Script [ ] 
Else 
Exit Script [ ] 
End If 
End If 

Link to comment
Share on other sites

I use a relationship based on a calculation field that concatenates first, last and facility names to get a hopefully unique key

 

Patient Already here is a summation field that counts # of related records

 

then run this script

 

Verify Patient

Commit Records/Requests

If [ Patient::Patient Already here>1 ]

Show Custom Dialog [ Title: "Patient May Already Exist in Database"; Message: "This patient may already exist in the database,

please check if this is the same patient on the following screen"; Buttons: “OK” ]

Go to Related Record [ From table: “Patient”; Using layout: “Patient” (Patient) ]

[ Show only related records; New window ]

Show Custom Dialog [ Title: "Is this the patient you are looking for"; Message: "Is this the patient you are looking for?"; Buttons:

“Yes”, “No” ]

If [ Get ( LastMessageChoice ) = 1 ]

Close Window [ Current Window ]

Delete Record/Request

[ No dialog ]

Else

Set Variable [ $pat; Value:Patient::patient_id ]

Close Window [ Current Window ]

Exit Script [ ]

End If

Exit Script [ ]

End If

Close Window [ Current Window ]

Link to comment
Share on other sites

Thank you for your response! It looks good but I have 2 questions...

 

How do I set up the relationship for the summary count?

 

Where do I attach this script? The field onObjectSave?

 

Thanks!

Rich

Link to comment
Share on other sites

Would not the simple (my modus operandi smiley-smile ) approach be.

 

enter find mode
new record/request
set variable ($phonenum; phonenum)
perform find
If Get (Foundcount) ≠ 0
set field (Phonenum ; $phonenum)
end if

 

I don't know anything yet about triggers - not in FM10 yet, but this works in 9.....

 

It basically initiates a record request in FIND mode, storing the entered phone number in a variable to be stuck back into the field if find fails.

Link to comment
Share on other sites

This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

Terms of Use