Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

Creating related records using global fields


This topic is 7702 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

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.

Posted

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

This topic is 7702 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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