Hefty517 Posted March 14, 2008 Posted March 14, 2008 I am trying to write a script which, and a record is deleted, it will create a record of it's deletion. The issue is, one of our departments will print a report of all jobs due that week, and if a job is deleted, there is no notification. I have created a very basic table and layout, with the fields of order number, job title, original due date, and date deleted. I have played around with a script, in which when the delete button is pressed on a record, prior to its deletion it will copy the above fields into a new record in the deleted job layout. However, I am having an issue copying the information over into the new table. It will create a new record, and records the timestamp of deletion, but does not input the order ID, job title, and original due date. Any help on this would be appreciated.
Charles Delfs Posted March 14, 2008 Posted March 14, 2008 If you could post your script that you are using I am sure we can find the problem as this is a simple task. Basically a simple way to do this is to create variables for each field you want to archive, switch to the new table layout, create a record, and use set field to set all the fields of that new record. Charles
mr_vodka Posted March 14, 2008 Posted March 14, 2008 The way that I would handle this would be to either use a lookup or import to copy your data from one table to the other. I would also leave the orig record in there minus all the data with a flag saying that it was archived in case you ever need to put a record back. See here
Hefty517 Posted March 14, 2008 Author Posted March 14, 2008 Here is my script as it currently stands: (Starting from within the record to be deleted in the Active Jobs 2008 table & layout) Go to Layout ["Deleted Jobs 2008" (Deleted Jobs 2008)] New Record/Request Set Field [Deleted Jobs 2008::Job Num; Active Jobs 2008::Order ID] Set Field [Deleted Jobs 2008::Media; Active Jobs 2008::Media] Set Field [Deleted Jobs 2008::Client; Active Jobs 2008::Client] Set Field [Deleted Jobs 2008::Original Due Date; Active Jobs 2008::Material Due Date] Go to Layout ["Active Jobs 2008 Form View"(Active Jobs 2008)] Delete Record/Request[] With this current script, it does create a new record, and it does delete the original record, but it does not copy the information over mentioned in the Set Fields script steps.
mr_vodka Posted March 14, 2008 Posted March 14, 2008 IF you start from your active jobs layout and you have a relationship to your Delete Jobs TO keyed on the primary key with allow creation of record on, you can simply set the fields from the active job side. The way you are currently doing it, you will need to store each of those into a variable since when you create a new record it does not relate to anything or set a key field to grab the rest of the data in the other fields. Again, you should be able to do this with an import or if you have lookups or autoenters for each of the corresponding fields in your Delete table then it coudl be done by just setting the key field.
aldipalo Posted March 14, 2008 Posted March 14, 2008 I would have thought that you could set up a filtered relationship and just show those records marked ACTIVE. However, no matter how I tried setting up the relationship I could not get it to work properly (Only show the active contacts on the Active_Contacts Layout). The only way was in a portal within the ALL_Contacts layout. Why is that?
mr_vodka Posted March 15, 2008 Posted March 15, 2008 I agree with you that this is better served with a status field and filtering, however I have found that many users want archiving. As for having a layout that show the active only records, wouldnt a GTRR solve that issue?
comment Posted March 15, 2008 Posted March 15, 2008 I would have thought that you could set up a filtered relationship and just show those records marked ACTIVE. However, no matter how I tried setting up the relationship I could not get it to work properly (Only show the active contacts on the Active_Contacts Layout). The only way was in a portal within the ALL_Contacts layout. Why is that? This seems to be a popular question lately. See: http://www.fmforums.com/forum/showtopic.php?tid/193634/ http://www.fmforums.com/forum/showtopic.php?tid/193924/
Hefty517 Posted March 17, 2008 Author Posted March 17, 2008 Sorry I didn't respond sooner to everyone; got stuck in a meeting Friday afternoon. I used the Set Variables script step for the Order ID, which was set as the related field in the TO, and everything worked perfectly! I am just now getting intimate with script steps, and I wasn't aware of the set variable step until you guys mentioned it...seems like that is a handy one I will have to remember for the future! Thanks again for everyone's help.
Recommended Posts
This topic is 6096 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