Richard:
Thanks for your response. Sorry it's taken a few days for me to
reply, but work gets in the way sometimes. I have a few of questions.
One is the field "Main Recd ID" created in "Parts"? and is it a
global? Two is the "record ID" the Get (RecordID) function or my
created job number? I assume it's my number, but I want to be clear.
And three in the Parts section of the script the find on the Main Rec
ID matching the Old Record ID isn't a option, I believe, because
these are global fields.
Thanks,
Peter
On Oct 6, 2008, at 2:52 PM, Richard S. Russell wrote:
On 2008 Oct 6, at 11:21, Peter Kilcoyne wrote:
Hi Folks:
My question is what's the best method to dupe records? I have two
databases, one is the "main" database where using a portal the
user creates and view "parts" of the main job that will live in
the second database. But since a majority of the work we do has
been done last year and only needs minor updates, I want to
duplicate the older "Parts" into the new "Main" with a new job
number which is auto generated via a script when a new job is
created.
The idea is the user would search the records for the job they
want to dupe and via a script the would be able to import/dupe all
of the records associated with that job into the new "Main" job
with the updated job numbers. Then they can go about making the
minor informational changes manually
Any ideas?
TIA:
Peter
Here's how I'd do it.
In "Main" create global fields for "Old Record ID" and "New Record
ID". In "Parts" create global fields for "Record Count" and "Step
Number".
In "Main" create a "Dupe" button and attach it to a script called
"Dupe Main and Parts".
Within that script, start by saving the current record ID into "Old
Record ID". Then duplicate the existing "Main" record and save ITS
record ID in "New Record ID".
Next the script turns its attention to "Parts", where it does a
Find for all records where "Main Rec ID" matches "Old Record ID".
Fill "Record Count" with "Get ( FoundCount )" and "Step Number"
with "0". Sort by anything. (Doesn't matter what; the idea is that,
in a sorted list, duplicates get added immediately after the record
they're a dupe OF, while in an unsorted list, they get added to the
end of the list.) Go to 1st record. Start a loop which will end
when "Step Number" equals "Record Count". Duplicate the record,
change "Main Rec ID" to "New Record ID", add 1 to "Step Number", go
to next record, end loop.
Last script step should be to return to "Main", where you will see
your newly created "Main" record and all its associated "Parts"
records displayed in their portal.