Jump to content

Duplicate Records Script


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

Recommended Posts

Can anyone help with a script to generate 10 new records. The records in 2 fields are to be a sequential increase in value by 1 from the previous record but the record in a third field is to be the same for all the new records.

Thanks

Link to comment
Share on other sites

  • 1 month later...

SetField(g_n_counter, 10)

SetField(g_n_field1, 1)

SetField(g_n_field2, 1)

SetField(g_t_field1, ""data you want"")

Loop

NewRecordRequest

SetField(field1, g_n_field1)

SetField(field2, g_n_field2)

SetField(field3, g_t_field1)

SetField(g_n_field1, g_n_field1 + 1)

SetField(g_n_field2, g_n_field2 + 1)

SetField(g_n_counter, g_n_counter - 1)

ExitLoopIf(g_n_fcounter = 0)

EndLoop

My shorthand is as follows

g_n_... = global number

g_t_... = global text

Link to comment
Share on other sites

'g_n_' just the naming convention I use. The field should be defined as a Global Number field under your field definitions. You may name the fields whatever suits you best.

Link to comment
Share on other sites

Set up a a constant relationship. In the two files you want to relate together, create a constant key,... define a field as a calculation, = 1, defined as a number. Create the relationship in the file you want to push the information from. In the table where you have the stored data, set the stored value into the related global field. You now have the data at your disposal.

Note that there are several ways to get this info, but this should suffice your needs and shows one way to utilize a constant relationship.

Link to comment
Share on other sites

In versions < 7, an invalid relationship (e.g. global to global) can work much faster than a constant to constant one, especially if there are hundreds or thousands of records in the related file, since the constant relationship has to get the ids of all related records first.

In version 7, global fields are accessible without a relationship. You simply Set Field [table::global, table1::field] or Set Field [table::global, value].

Link to comment
Share on other sites

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