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.

Create record in related one-to-one table?

Featured Replies

  • Newbies

Hi,

Is there a way to automatically enter data in fields of a related table when you create a new record in a table it's linked to? I have two tables--the main "data" table, and its related "lock" table with fields for whether the data record is new, imported, exported, or locked. When I create a new record in the data table, I want a new record created in the lock table at the same time, with initial values of locked being false. I have the locked field placed on the data layout, but the value is empty when a new record is created.

It's a one-to-one relationship, and "allow creation of records" is checked.

Any ideas?

Thanks,

Matt

masterlock.zip

Unless there is a compelling reason not to, one-to-one relationships should be eliminated and the tables combined. It's not clear what the purpose of these tables are.

To answer your question: while it's possible to create records in multiple tables through relationships, it's not possible to automatically create records in related tables when a record in the current table is created. You could use a script to do this.

Matt

If you are scripting the creation of the new record then you could simply add a line,

Set field (The field you want to set,''Locked'')

immediately after the create new record line.

If not scripting then set the field (in define database - fields) to have an auto entry of data 'Locked'

Phil

ps I defer to ender cos I didn't look at your file and......he is a lot cleverer than me!!

Edited by Guest
posted before I saw enders reply

  • Author
  • Newbies

Thanks Ender and Phil.

This is just a dummy database--I'm trying to get record locking to work (as well as scripted exporting/importing). If I put the record locking field in the main table, it can't be unlocked later by the user when the record is locked, so I thought I could put it in a separate table.

I have auto entry set up, but because no record is created, nothing is set. I tried writing a script to make a "new record" button that would create a new record in each table, but I can't figure out how to specify which table to put a new record in--it just makes two new records in the data table, and does nothing to the lock table.

New Record/Request

Go to Field[select/perform; lock::Locked]

New Record/Request

Set Field[lock::Locked]

Is there an easier way to allow users to lock a record, and then unlock it later when they need to make a change?

Thanks,

Matt

  • Author
  • Newbies

Oops! Forgot to enter a value! This seems to work:

New Record/Request

Go to Related Record[From table:"lock"]

Set Field[lock::Locked;"N"]

I think the whole Lock table can be eliminated.

Can we assume you are using record level privileges to decide if a user can edit a record? If so, then simply build more conditions into that calc:

Status = "Open" or

CreatedBy = get(accountname) or

get(accountname) = "admin" or

gOverride = 1

...

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.