Jump to content
Server Maintenance This Week. ×

Duplicate record X times


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

Recommended Posts

Hi,

I have a FM database with one table with 28 columns.

The first field is named: “RegNumber” which requires a unique value, in my case, something like: nsza001001

I create a new record, let’s say,

RegNumber: nsza001001, the remaining fields are filled with other values.

Now, I would like to duplicate the above new record an X amount of times, 5, 10, 15, whatever.

What I need is this:

1) A field where I can type the amount of duplicates I would like to make.

2) A script I can trigger, that can duplicate the new record the amount of times I need, at the same time increment the unique “RegNumber” of the original record by 1, and assign the incremented numbers e.g. nsza001002, nsza001003 etcetera, to the duplicates.

Any help would be appreciated

:(

Link to comment
Share on other sites

Before we answer the remaining portion of your question on providing a global to enter the number of times to duplicate and looping, we need to know how your reg number is currently created. Is it an auto-enter serial? If so, and you duplicate a record, it won't duplicate the reg number but will increment it appropriately.

Link to comment
Share on other sites

regarding the uniqueness of those numbers I have full control over.

Sorry, but I doubt you have full control over it. And this is an issue. If you want to auto increment the RegNumber when you duplicate it then why don't you have it as auto-enter to begin with which is the ONLY way to safely generate a serial (unless you use a specific serial table in which case we need to know that)?

Can you change your process? If not then we need to know specifics on how you create that number and what protections are in place. What if someone else runs the script at same time? There are many things which can go wrong and without thinking it through carefully, it can bite you. :crazy2:

Edited by Guest
Corrected typo and then added sentence
Link to comment
Share on other sites

I suppose You're right, Full control is an exaggeration.

Thank you for your concern, advice and warning. I appreciated

Of various reasons The “RegNumber” cannot be changed to Auto-generate serials.

The “multidublication” function is only to be used (if needed) in combination with a new record creation.

The numbers I am using are unique.

No one is in possession of the same RegNumbers, Therefore, it is very unlikely that too persons to punch in the same number at the same time, but yes, it can happen by accident or bad luck.

What will be the consequences if it happens? Do you know?

Is it possible to construct a script that takes such a conflict situation in consideration?

If the only bad thing that happens is the script to stops, that is OK with me.

Edited by Guest
Corrected sentence
Link to comment
Share on other sites

Can you explain the absense of relations as such, to be fair is table with 28 columns and nil in common is a fairly large figure of diversity a figure of 134217728 comes to mind ...

What I try to say is, you're starting off in a wrong way by keeping things in abstractions only - real guidance is based on a brief description of context and purpose, and not what the initial hunch for structure might lead you to, since it can be polluted by methods and realms attempted pulled over from a different tool, where it makes more sense. I dare hardly anything by assuming it's the case in this thread as well.

A fellow developer, has a good saying on this:

The rule is; give the client what he needs, not what he wants. If you

give him what he wants he is going to be VERY upset with you.

Here are you perhaps not exactly client in the strictest sense, but your wish to get help to 28 columns is not far from asking for help to be barking up the wrong tree.

http://en.wikipedia.org/wiki/Third_normal_form

Then to the last encounter of serious doubt on my behalf, custom functions have usually no jurisdiction beyond the record as confined realm, I know of no way a custom function in the filemaker sense of the matter, could generate new records at all ... please teach me here!

--sd

Link to comment
Share on other sites

I have been hesitating answering. Like Søren, I worried about the 28 columns since it indicates 28 'like' fields and could be improper design. However, you rate yourself Intermediate so I then thought you might be working with a calendaring type situation and those 28 columns might not even contain same type data. So I bypassed my concerns about why you might want this and turned to your serials.

What will be the consequences if it happens? Do you know?

No I don’t know the consequences of duplicates because I don't know how you are using this RegNumber; whether you are using it as a primary key which binds relationships or whether it's just a display number.

And I still don't know how you are making that serial number. Nor do I know why you are duplicating records or how the process will appear to an end user. Really, we ask questions for good reasons and it isn't easy to assist without the information we request.

However, I will show you a loop. It is based on finding the last existing number and incrementing from there. I also don't know if you want to specify the starting number instead of using the last created number so you'll have to modify it to fit your needs. Use this script at your own peril but I hope it at least gets you moving forward a bit. :wink2:

DupLoop.zip

Link to comment
Share on other sites

Dear LaRetta,

Thank you, that is exactly what I needed.

The RegNumber is a primary key that binds relationships to others tables and fuktions. A “global” disaster can happen if I am not careful.

I will test and retest the Duploop script in a copy Database before I make any final dicition.

I may or may not use the loop, but it gets me moving. Thank you again :(:):P:):)

Is only to be used (as you correctly mention) on an unsorted set, on the last entered/existing number and only the admin can use the loop.

If it works as I imagine, it will be a very helpful fuktions, sometimes we have to duplicate quite a few records with partly the same values. Very time consuming.

Edited by Guest
Corrected sentence
Link to comment
Share on other sites

This topic is 5277 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.