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 related records using global fields

Featured Replies

  • Newbies

Hello,

I've just returned to using Filemaker, so my knowledge is a little dusty.

I have a file storing data about all of the companies we deal with. Within a layout, I have a portal listing all employees of the company. I also have a button to create a new employee in that company. The employees are related to the company using a company ID code.

In the past, I have had a script which copies the company ID code, opens the Employee file, and runs a script in the Employee file which pastes the company ID. I now know this is bad practice. It did seem a little inelegant.

I have been told that you should use global fields. I assume that you are supposed to store the company ID in the global field during the process. I am worried that two users might create new employees simultaneously and one user might replace the value of the global field before the other has completed the process.

Is there anyone willing to enlighten me?

Cheers,

Don.

Hi Don,

Create a global text field in your Company db called gCompanyID. Then within your Employees, create a relationship from Employees to Company on the Company ID maybe call the relationship Company.

Your New Record script in Employees:

Go To Layout [YourNewRecordLayout]

New Record Request

Set Field [CompanyID, Company:gCompanyID]

Have a 'Go Back' button that, when they are done, will have a script of: Go To Related Record [show Only Related, Company] and Go To Layout [Layout with your portal]

Your script in Company that you attach to the New Employee Button above your portal would be:

Set Field [gCompanyID, CompanyID]

Perform Script [sub-script External, Employees.fp5] and point to your new record script in Employees.

Also, in your Define Relationships (from within Company), turn off 'Allow Creation of Related' and this way, Users won't be adding a new record via clicking into a blank row in the portal.

I am worried that two users might create new employees simultaneously and one user might replace the value of the global field before the other has completed the process.

Don't worry about it. Globals are specific to each User, so there won't be a conflict at all. They can both create a new Employee record at the exact same time. smile.gif

LaRetta

  • Author
  • Newbies

Oh, great! Thanks a lot. Much appreciated.

Don.

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.