Skip 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.

script to add surrogate key to existing files

Featured Replies

  • Newbies

Hi....I have an issue with adding a surrogate key for already existing database. I have crated a treatment key as a surrogate key for all values of medical record number..but am unable to populate it with incrementing numbers. Tha maximum I could get to was...populating the treatment key with same value. Plz help me to change these numbers to incrementing numbers...rather than same vakue.

I do not know which category to use in the scriptmaker to initiate a count to increment numbers by one after each loop.

Plz help me out with this!!!

Version: v6.x

Platform: Windows XP

If I'm understanding your question correctly:

1) Define a global number field "LoopCounter"

2) show all records you want to set the surrogate in and sort the way you want them to increment.

3) The important parts of the script:

Set Field ["LoopCounter", "1"]

Loop

SetField ("surrogateKey", "LoopCounter")

Exit Loop If ["Status (CurrentRecordNumber) = Status (CurrentRecordCount)"]

Goto Record/Request/Page [Next]

Set Field ["LoopCounter", "LoopCounter + 1"]

End Loop

Is this what you wanted to do?

  • Author
  • Newbies

Thanks ...it did help a lot....i just had to reassign the value of loopcounter as the surrogate key and take the next value of loopcounter as previous record of loopcounter +1.

that did it!

thanks

I didn't mention this in my first post, but:

Look at the script step Replace Contents. It replaces the contents of a field with a value which can be a serial #, a calculation, etc. It works across all records in the found set. It will be faster than the loop. In your case it would look like:

Replace Contents [No dialog, "SurrogateKey", "Serial numbers"]

Things to note:

1) It operates on records in the Found Set, if you want to do this for all records be sure to include a Show All records step before.

2) It uses the current sort order, so make sure the records are sorted the way you need.

3) Check the No dialog if you don't need to change anything in the replace dialog (like starting serial #, etc).

Version: v7.x

Platform: Mac OS X Panther

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.