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.

New record in related database

Featured Replies

I want to have a script that will create a new record in a related database and put the ID in the ID field. I tried

Copy Record

Open ("RelatedDatabase")

New Record/Request

but this creates a new record in the database I'm in. And the RelatedDatabase flickers on the screen suggesting that somehow the script is touching it.

BTW this will not be the only file in the RelatedDatabase with this ID. I'm storing multiple notes about the ID in the RelatedDatabase. The information shows up in the main database through a portal. I got this working (and it seems more complicated than what I want to do, but then it's not scripting).

Can't be that hard. Seems like a natural thing to do. Book by Schwartz didn't help me either

This has probably been answered somewhere, but although I've used FM for years, I am only scratching the surface. I wrote scripts attached to buttons to take me from the RelatedDatabase back to the main one, so have some of this figured out, but I've never tried to move data from one field to another escept of course by calculation.

Thanks

RE: Copy Record

Open ("RelatedDatabase")

New Record/Request

but this creates a new record in the database I'm in.

Naturally. Your script is running in first database and it just open the second, related db. Then it created new record in first db, where script is executing.

Move the New Record/Request into related db and call that script instead of Open ("RelatedDatabase")

  • Author

Thank you. I knew it would be easy. Just too much of a newbie to think about it right. But I still don't have it.

How does the script know which record I was in, since I want the IDs to be the same? I tried copy record, but don't see any other commands that make sense. The script now does create the new record in the correct file.

Thanks again for any help.

Hey Mountainbiker,

There are numerous ways to achieve what you want to do, so I'll justtry to explain one...

I'm assuming you already have a relation between the two databases.

? create a global field that will hold the ID. Call it something like gID.

? create a script in the database that you want the new record to be created in. The script should do something like:

New Record

Set ID, gID

? create a script in the main database with the following steps:

set gID, ID

perform script ( external script, script made in previous step)

refresh windwow

Last step is to get you back to your main, calling database.

Hope this helps,

Keep biking!

Ernst.

Hi,

The easiest method.

Turn your relationship to allow creation of related records.

Then, simply enter the notes you want to create in the new portal row. The ID will instantly be populated in the related file.

Now Ernst method would be OK. As you said "newbie", read second script from Ernst as Set ID, ???:g_ID.

"::" is the sign for your relationship !

  • Author

Thank you both Ernst and Anatoli

I learned from both of you. But I think I'll stay with simple.

I just deleted my message asking for more help. I wanted a list from the related database to appear in the main database for data entry. I just figured it out. The key was to use popup menu in the item in the portal.

Thanks to both of you for your help.

  • 1 month later...

I am interested in doing this the hard way, so I'm looking for some hints.

Script in related database

New Record

Set ID, ::gID

Script in the main database with the following steps:

set gID, ID

perform script ( external script, script made in previous step)

I've tried the two scripts and they work to a point. I get the new record in the related database, but the ID number is not added. Does the script stop at the create new record? I've tried adding a resume button to resume the script and add the ID after the user inputs the record information but that does not seem to do anything.

Help.

Hi:

Make your gID field a global field.

Duh, thanks kenneth.

I put the "g" in front of the variable, but forgot to make it global! It's always in the details.

Scott

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.