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.

Creating New Records in a Related Table

Featured Replies

  • Newbies

Is there a way to create a new record in a related file/table?

I am currently working with a database that consists of two file/tables. There is a one to many relationship between the two. The main file/table contains data on the clients office, while the second file/table contains information on the clients (there can be more than one client at a given office.) The user logs into the "client office" file/table and is able to view and manipulate the information in the "clients" file/table via a portal.

The problem I am having is: When a new client offices are created how would I go about creating a new record in the "clients" file/table from the "client office" file/table, is there a script command that can be used or another technique that can be used?

Thanks in advance.

Pav

Set up a script in Client Office that calls a script in Clients that creates the new record. You could also 'Allow creation of related records' in the portal's relationship definition, then create new Clients just by typing into the last row of the portal.

I'm currently trying to do the same thing (via "Allow creation of related records") but the obstacle that I'm encountering is that I have a unique key (auto-generated serial number) in the parent table in which I want to create a new record. The reason that this is a problem is that when I'm trying to enter data in the parent table's fields, I keep getting the error message "This field cannot be modified until the field <unique key field in parent table> is given a valid value."

So, in this case, do I necessarily need to create a script that creates a new record in the parent table ? It seems a little bit unnecessary to have to create a script simply for the creation of a new record.

  • 2 weeks later...

You're creating parent records from child records? Isn't that a bit backward?

Well, if you have a one-to-many, then you could just put the parent fields directly on the child layout. If you have your relationship set to allow creation of related records on the parent side, then when you enter data into the related parent fields, the relationship will be forced to exist and a new parent record automatically created. Of course, this will need to be a different relationship than the one from the parent's unique id to the child's foreign key, since the parent's unique id will not yet exist. Once the parent record is created, its id can be set in the child's foreign key via script and you can then reference the parent record through the primary relationship without issues. The alternative, of course, is to script creation of a new record in the parent table and then set the child's foreign key, which may be more suitable to your purposes.

Again, though, the question is why would you want/need to do something this way instead of the natural way, from parent to child?

I'm trying to do a similar thing. See attached graphic.

I have a Case Table, a Review Table and a Review Assignement table that links each Case to one or more Reviews (i.e., a given Case may have 0, 1 or many Reviews assigned to it). Each Case gets a unique, auto-entered, serial ID (CaseID) and similarly for each Review. These are the corresponding Primary Keys in each table.

What I would like to do is have a button on the Case-layout called "Add Review" which would create the related Review Record and take the user to the "Revew Data Entry" Layout so they can add the review data. I'm completely stuck on how to proceed so any help would be greatly appreciated. (I've seen how to use a portal in the Case Layout, but I don't want to do that in this case. I also think that understanding the scripting approach will help me understand how to implement this in the separation model when I move to that - but for now I want these 3 tables in the same file.).

CaseReviewRelationship.jpg

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.