AnsweredAssumed Answered

Nested If w/ Custom Dialog

Question asked by greengk2fi on Sep 17, 2015
Latest reply on Sep 17, 2015 by greengk2fi

I've created a basic script for deleting a client so I could offer two different warnings about deleting clients. The script first determines whether or not a client has services/sales associated with it. If the client does not, the user receives a simple warning saying the deletion cannot be undone. The user can choose to Delete or Cancel.  If the client has services, the user receives a bit more of a warning telling them that they shouldn't delete a client with services unless the record is a training dummy.

 

The script works perfectly for clients without services, the appropriate warning appears and cancelling cancels the script and deleting deletes the active client and then shows all clients. The script begins to work for the second case for clients with services/sales. The appropriate warning appears; but deletes the client record whether or not the user selects Cancel or Delete. I've looked at the script for a long time trying to find a problem in matching Ifs or responses. I can find none unless the second instance of getting the button response needs a different integer rather than [ Get (LastMessageChoice) = 1 ] . The full script is below. Any help is appreciated.


 

DeleteClient

Set Variable [ $CurrentClient; Value:tblClient::_pkClientID ] Go to Object [ Object Name: "All Services" ]
Enter Find Mode [ ]
Set Field [ tblClient::_pkClientID; $CurrentClient ]

Set Field [ tblService::ServiceDate; "*" ] Set Error Capture [ On ]
Perform Find [ ]
If [ Get(FoundCount) = 0 ]

Enter Find Mode [ ]

Set Field [ tblClient::_pkClientID; $CurrentClient ]

Perform Find [ ]

Show Custom Dialog [ Title: "Permanently Delete?"; Message: "Deleting a client cannot be undone. To keep this client's record select Cancel. To delete this client select Delete."; Default Button: “Delete”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]

If [ Get (LastMessageChoice) = 1 ] Delete Record/Request

[ No dialog ] Show All Records

Go to Object [ Object Name: "Client Information" ] Else

Exit Script [ ] End If

Else

 

    

 

Show Custom Dialog [ Title: "Deleting Client Data Cannot Be Undone"; Message: "This client has service records. If you delete this client, you will lose not only his or her information; but all of their services and associated records.¶¶Deleting a client with services should be avoided unless it is a fictional client you have used for training.¶¶To keep this client, select cancel. To delete this client permanently, select Delete"; Default Button: “Delete Client”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]

Delete Record/Request

[ No dialog ]
If [ Get (LastMessageChoice) = 1 ]

Delete Record/Request
Show All Records
Go to Object
[ Object Name: "Client Information" ]

Else
Exit Script
[ ]

 

 

End If End If

 

Outcomes