Jump to content
Server Maintenance This Week. ×

Duplicate record script not working consistently


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

Recommended Posts

I need some help seeing what I am doing wrong with a duplication script that I have. Here is the database layout:

4 tables: Project;KitCode;EventCode;ProductCode

The project table is related to each of the other tables via a ProjectKey. ProjectKey is automatically entered number.

On the main layout (Project table) I have 3 portals showing records from each of the other tables. Often our users want to duplicate a project because a new project they have is very similar to the old one so they need to just change a few entries as opposed to entering all the info in again.

I have a main script (Duplicate all codes) that copies the old projectKey to a global field and then it duplicates the project record. After that, it fires off 3 duplicate scripts for each table. The scripts are all basically the same. I do a search for any entries that were related to the old projectkey. If there are any, I duplicate the record and change the projectkey to the new projectkey.

The script will fire correctly and duplicate everything like it should. If I fire it again, then it will not duplicate any of the code tables. I don't know what i am doing wrong.

I attached a shrunk down version of the database that will hopefully make it easier to understand.

Thanks for the help!

John

CodeRequestCopy.zip

Link to comment
Share on other sites

Sorry, forgot about that.

Use laker_42 for both username & password.

Another note, after downloading it. Run the duplicate all codes script. It will work the first time. If you delete the record that it just created and rerun the script, it will not duplicate the codes.

John

Link to comment
Share on other sites

Attached is a working version that uses only globals from the Project table. You can access globals from any file using any (or no relationship); so there's no need to set multiple globals with the same value, in individual tables. It also uses the natural relationships to access related records, instead of using a find, and uses not IsEmpty to test for related records, which is more appropriate to use than IsValid.

CodeRequestv2.zip

Link to comment
Share on other sites

Queue,

Thanks for the help. I did originally have it using the global fields in the project database but I was trying something else to see if it was the problem. A couple of questions:

1) What are the 2 new relationships that you created accomplishing?

2) In the event code duplicate script, you have an extra step at the beginning that isn't in any of the other duplicate scripts. It is Go to related record [From table:Project|OldKey;Using layout <current layout>] [show only related records]

I was just curious why this isn't in the other scripts.

I really appreciate you taking the time to help me out on this!

Thanks!

John

Link to comment
Share on other sites

The two relationships are simply to make it easy to navigate between the original and duplicated record, regardless of the found set or sort order. The first relationship's 'left-hand' key is a global containing the original record's id. The second relationship's 'left-hand' key is a global containing the new record's key. Once the Duplicate Record step is performed, focus is on the new record, using GTRR [Project|OldKey] in the DuplicateEventCode script forces focus to be returned to the original record, making it easy to GTRR to the EventCodeRequest, KitCodeRequest, and ProductCodeRequest records afterward.

Once the original record is focused, there's no need to reference the Project|OldKey relationship again, which is why it doesn't appear in the other subscripts. When you Go to Layout [Original], this record should still be focused. If you want to make the subscripts more consistent, you can move the GTRR step from the DuplicateEventCode script to the DuplicateAllCodes script, just before the step to perform DuplicateEventCode.

Once the related records have been duplicated, the GTRR [Project|NewKey] step returns focus to the new record, so the process is seamless to the user.

I just noticed that I have 'show only related' selected for the Project|OldKey and Project|NewKey GTRR steps. You may want to remove that since it will isolate the old record during the script and the new record at the end of the script, which will change your found set and probably annoy your users. shocked.gif

Link to comment
Share on other sites

  • 5 weeks later...

I have the exact situation and I followed this example and a strange thing happend.

I have "Show only related records checked" in DuplicateEventCode (that is the first related record) as you have on your example. This works perfect on laker 42 example.

However, when I did the same thing on my example all the records in the file were displayed. For the fun of it I unclick "Show only related records" and it show only related records. In other words the "show only related records is doing the opposite.

Link to comment
Share on other sites

Thank you for your help!! Sorry I took so ong getting back to you I had t get my computer off the bottom of the pool (just kidding).

I have cloned my file and eliminated all non relevant parts.

I start on layout "job ticket" There are two scripts the first triggers the second. In the second script I halt script because thats all the further I have gotten in the test. It is the second item on the second script that is not working.

In the enclosed version I am getting whatever the last found set was in art line items. Checking related records has no effect.

In my full blown version I tried the script on another record and layout displayed the records not related to the parent record.

I sure this is simple but I have stared so long I am seeing pink elephants.

Clone.fp7.zip

Link to comment
Share on other sites

I just solved my problem. I was switching to the related layout. (first step in second script) then using the gtrr step. So I was starting at the wrong spot and losing my context>

Link to comment
Share on other sites

This topic is 6995 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
×
×
  • Create New...

Important Information

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