Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Conditional number increments - a little help here please

Featured Replies

  • Newbies

Hi folks,

I'm attempting to modify an incremental numbering script to include a conditional step, but since I just started playing with FM a few days ago, I'm having some problems.

The idea:

I have a script that increments the visible (not Internal) record ID's by +1.

What I would like to happen is to round up the record ID to the tenths if the last ID digit does not end in zero. Then, the subsequent ID's in this batch should start at zero and increment by +1.

In other words, instead of getting a sequence like 96, 97, 98, 100, 101, 102... I would like to get a sequence like 100, 101, 102, 103, 104, and then 110, 111, 112, 113 the next time the script is run.

What I have so far:


If (table1::record_id < 10*Ceiling(table1::record_id /10)

Set Field [table1::record_id; 10*Ceiling(table1::record_id /10)]

Set Field [table1::next_record_id; table1::record_id]

The problem:

The next step step, or course, is to increment the next record and so on, but what I've tried has been to make some baroque combination of greater-than/less-than calculations to push the next record incrementation past the rounding up and to the rest of the script so that it would increment everything after xxx0 by +1 without rounding up again.

The problem is that I can only get these attempts to spit out a sequence like 1000, 1001, 1010, 1011... because the script eventually re-evaluates table1::record_id and table1::next_record_id and rounds them up to the tenth again.

I hope that I'm being clear with my description of the problem. I'd very much appreciate your suggestions--thanks in advance!

What do you mean by "I have a script that increments the visible (not Internal) record ID's by +1."

Do you intend to use your generated IDs as key fields?

  • Author
  • Newbies

What do you mean by "I have a script that increments the visible (not Internal) record ID's by +1."

Do you intend to use your generated IDs as key fields?

I just wanted to make the distinction with regard of what I'm looking for. I'm not touching the internal FM id, but only want to change the pattern of the generated record IDs.

The generated IDs will be used for simple searches of that particular ID, but nothing more complicated than that. I just prefer to make each set of generated IDs for each script session to start at a number rounded-up to the tenth from the last generated ID.

Sorry, still saying, "huh?" What are your keys? What do you mean by internal record IDs?

You could try something like the attached. However, this doesn't seem to be a good method overall for several reasons - most importantly, the lack of any audit trail.

BatchID.fp7.zip

  • Author
  • Newbies

Sorry, still saying, "huh?" What are your keys? What do you mean by internal record IDs?

I'm sorry for not being clear. "Internal record IDs" in my case are the FM unique record IDs. On top of those, there are arbitrarily generated IDs associated with each particular record. These latter IDs are the ones I wish to modify.

OK. So these generated numbers are not used as keys in relationships. You have another field that is set to auto-enter serial and is the primary key for the table. Good.

  • Author
  • Newbies

OK. So these generated numbers are not used as keys in relationships. You have another field that is set to auto-enter serial and is the primary key for the table. Good.

Correct. The intention is that these generated numbers are "modifiable." I'm trying to play around with the existing incremental numbering script that creates these in order to make the pattern I mentioned in the OP.

These generated numbers are quazi-IDs for records in a table. There shouldn't be more than 10 records for every instance of ID generation, so I'd like to have each batch round up the last ID to the tenth, then increment by +1. This process should repeat whenever the script is used again.

It's a genealogy application, if that helps... Each new offspring gets an incremented quazi-ID, but each new set of births starts being numbered by rounding up the quazi-ID of the last member of the last set of births to the tenth.

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.