ssimons Posted October 26, 2005 Posted October 26, 2005 right now i have 2 databases setup called Contact Type and Deleted Contact Type. What I want to do is when a record is deleted from the Contact Type database I want to record it into the Deleted Contact Type database (for recovery purposes, if needed). The only way I've been able to come up with doing this is when the Delete button is pressed, doing a find and exporting the record to a file, then deleting the record and going to the Deleted Contact Type and importing the file. I know there has to be an easier and more effiecent way of doing this. Anyone have any suggestions?
Kent Searight Posted October 26, 2005 Posted October 26, 2005 Try something like the following: Make all the fields auto-enter calculations(except the key field) in your Deleted Contact Type table. They will get their values from the corresponding fields in the Contact Type table. Script as follows: Create a new record in Deleted Contact Type table. Set the key field to the same value as the key field in Contact Type table. Go back to Contact Type table layout. Delete record. ----- That's it. All the data from Contact Type table is auto-entered into Deleted Contact Type table. Just make sure you test the script thoroughly before you commit to deleting records! :)
Sanjai Posted October 26, 2005 Posted October 26, 2005 (edited) Create a script in deleted contact type table to import the record from contact type table. In a layout in contact type table, when the delete button is pressed, do show all records, omit record and show omitted to keep the record being deleted in the found set. Then call the script from delete contact type table to import the record. The last steps would be to delete current record from the contact table and do show all records. Since you are keeping track of history item, I would advise you to transfer the datedeleted and deletedby fields in deleted contact type table. It is a good idea to keep a primary key in deleted contact type table. Kent and myself were replying the post at the same time. His solution would be faster and easy to maintain. Edited October 26, 2005 by Guest
Kent Searight Posted October 26, 2005 Posted October 26, 2005 Hi ssimons, Whichever way you decide to handle this, I would recommend you follow Sanjai's sound advice about... Since you are keeping track of history item, I would advise you to transfer the datedeleted and deletedby fields in deleted contact type table.
ssimons Posted October 26, 2005 Author Posted October 26, 2005 Yes, I agree and I do have a deleted by and a deleted date/timestamp field in the Deleted Contact Type table. Kent - I've been working on trying your suggestion, but I must be doing something wrong or missing a step. Here's what I have..please let me know what I might be missing, if you can tell. Table - Contact Type Fields - Contact Type Contact Key Created By Created Date Update By Update Date Table - Deleted Contact Type Fields - Deleted Contact Type Deleted Contact Key Deleted Created By Deleted Created Date Deleted By Deleted Date Relationship - Deleted Contact Key = Contact Key I set the set the following fields to be auto-enter calculated values.. Deleted Contact Type = Contact Type::Contact Type Deleted Created By = Contact Type::Created By Deleted Created Date = Contact Type::Created Date When pressing the Delete it runs the following script... Enter Find Mode[] Go to Layout["CTTM-Form View Find"(Contact Type)] Go to Field[Contact Type::Contact Type] Pause/Resume Script[indefinitely] Perform Find[] Go to Layout["CTTM-Delete"(Contact Type Deleted)] New Record/Request Set Field[Contact Type Delete::Deleted Contact Key; Contact Type::Contact Type Key] All I'm getting is a new record in the Deleted Contact Type waiting for input.
Kent Searight Posted October 27, 2005 Posted October 27, 2005 Here's how I would do it: First, my key from Contact Type table would be a unique, auto-entered serial number. I would set a global field or a script parameter to that value from the record I want to delete. I'd set the key field in the newly created record in Contact Type Deleted from the global field or the script parameter. I'd set the "history fields" (who deleted, when, etc.) I'd finish the script, returning to the original layout, or whatever else it needs to do. --------- In a condensed version, that's it. If you're using a unique ID there's no need for the find you're performing...only one record will match one record, i.e. you're creating a one-to-one, temporary relationship. Bear in mind that the way in which you're attempting to set the field won't work. That's why I suggest a global or a script parameter for temporary storage during the script. Hope this helps!
ssimons Posted October 27, 2005 Author Posted October 27, 2005 Very helpful. I've got it working. Thanks for spelling it out for me Kent.
Recommended Posts
This topic is 6969 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