Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

I posted the following script and didn't get a response so hopefully if I expand more I will find some help

"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"

I'll expand further.........

I have a file where I need to have 3 fields, one for engineer, one for sample number and one for sample entry id.

When I first generate a new record I select the engineer from a drop down list from a value list (i've done this) and the sample number is generated from the auto enter_serial number function (again I am ok with this). The sample id should look at the previous record and add one to it.

Then I need a script to go on to generate x no. of additional records each with the same sample id and engineer as the first record generated above

I need to allocate x no. of sample numbers to the engineer each one more higher than the previous ie: W10000, W10001, W10002 etc.

The Engineer may submit 3 samples or they may submit 10 samples so the "x .no" above would be the number of sequentially increasing records that I need to generate.

The datebase will therefore be used as follows:

1. New record request

Correct engineer is selected from the drop down list

Next Sample number is automatically entered

Next Sample id number is entered

This is the first record generated

2. "How many more samples are you entering?"

Say 5 samples are being entered, the person entering enters 4 from a drop down value list with 1,2,3,4,5,6,7,8,9 as the list ( I'm ok with generating this value list)

The database script then goes onto generate 4 additional records each with the same engineer and sample id number but with the sample number increasing by one

You may wonder why I am trying to do this, I need a sample id number to use to link to each set of records in a relationship set up further down the database.

Hope someone can help and that I have been more clear in my desription. I haven't had much luck with replies on this forum so far. This is probably a simple script but I am new to script writing and don't know where to start.

Thanks guys

Posted

It sounds to me like the easiest way would be to duplicate the first record you have, then adjust the sample number, etc. You would have the number of duplicates desired in a global field, I'll call that gNoSamples. I call your sample number field SampleNumber, and assume your table is named DB.

Your script might look something like this:

Loop

  Exit Loop If [ DB::gNoSamples <= 0 ]

  Duplicate Record/Request

  Set Field[ DB::SampleNumber; SerialIncrement( DB::SampNumber; 1 ) ]

  Set Field[ DB::gNoSamples; DB::gNoSamples - 1 ]

End Loop

The global counts down as you duplicate records, the loop exits when no more are needed.

Hope this helps.

  • 2 weeks later...
Posted

Thanks for that.

I have netered the script and depending on the number I enter into the gNoSample that generates that number of duplicate records.

Can you help further?

I need one field to remain the same across all the duplicated field. Not sure what the script would look like but it should go something like this

After creating the duplicate record

Take field value from previous record

copy value

paste into same field of record just created

Thanks agin for your help smile.gifsmile.gifsmile.gifsmile.gifsmile.gifsmile.gif

Posted

When you duplicate a record, it should take the value from the previous record. If it's not doing that, then the field in question must have auto-entry options turned on. So, the simple answer is to disable auto-entry for that field. If you need auto-entry for some reason then I would script it like so:

Set field ( globalField, fieldToDuplicate )

New record # (or duplicate record)

Set field ( fieldToDuplicate, globalField )

It's good practice to get away from the copy/paste mindset and try to think more in terms of Set Field when possible, since it doesn't depend on field/layout access. And when you want to pass a value from one record or database to another, global fields are your friend.

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