I believe you may be able to accomplish this via a portal in your Accounts layout. All you would need is to create the portal to Contacts and under the Relationships graph, turn on "Allow Creation of records in this table via this relationship" for Contacts. This will automatically pass over the AccountsKey and create the contact based on information input by the user.
I already have this but it would be nicer to have a small interface to type the contact details but ive tried this through a popover button but it didn't work.
Often times I use a Settings table to store temporary data prior to creating a new record. The settings table contains all global fields and only one record. Using this table you could create the popover you want and pass the information from Accounts to Contacts.
Something like this:
Set variable $AccountID = Accounts::Key
Go to Layout Contacts
Set Field Contacts::AccountKey = $AccountID
Set Field Contacts::Name = Settings::ContactName
I use a variable for the Accounts key since you don't want the user to retype the key into a Settings field in the popover.
Also, be sure to clear the global fields at the end of the script since they will retain all data entered:
Set Field Settings::ContactName = ""
Hopefully this helps,
That would be helpful, Couldn't you just pass Accounts::Account_ID and Accounts::Company straight to Contacts Layout? As these are the only 2 fields im interested in.
Then they can manually type in contact details without a popover in the contacts layout.
You could via the use of variables like so:
Set Variable $AccountID = Accounts::Account_ID
Set Variable $Company = Accounts::Company
Go to Layout Contacts
Set Field Contacts::Account_ID = $AccountID
Set Field Contacts::Company = $Company
Since you are switching from Account to Contacts you lose the context to determine which Account_ID or Company data to grab from Account, hence the need for variables.
This is my understanding at least, someone may have information to the contrary.
Thanks, I've only passed Account_ID now.
Changed the company name to a calculation field which looks at the related account company name field.
1 of 1 people found this helpful
a) you shouldn't need a field in Contacts for the company name--neither a calculation field nor a text field is really needed as you can refer to the related table where you have the company name.
b) you might want to do a web search for "MagicKey" as a way to create these related records. It avoids changing layouts and/or creating a new window and this can be advantageous.
I ended up using MagicKey's on this occasion.
Funny to think this time last year I picked up filemaker for the first time