Jump to content

Add Record Button passing pk/name


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

Recommended Posts

I have a layout where it shows a Person's information (name address etc), and it includes a Tab Control that lists all the dogs that are related to (owned by ) that particular person.

I want to be able to click on a button that allows the user to add a new dog that is connected to the person showing. I have a Dog Details layout, I just need to pass the person key/information to the Dog Details layout so the dog is automatically added to that person.

I've attached a screenshot of the Person Details layout with the Tab Control, and the Dog Details layout, where I'd like to have the Owner field automatically filled in when added a new dog.

In my button control, I've tried a Single Step and the Go To Layout, and adding the Optional Script Paramater, using the Primary Key from the People Table, but it doesn't seem to be working.

I'm very new at this and I'm sure there is an easy solution for those experienced users.

Thanks!

Cynthia

 

Screen Shot 2017-06-13 at 2.22.21 PM.png

Screen Shot 2017-06-13 at 2.22.37 PM.png

Edited by Cynthia Heyman
Link to comment
Share on other sites

56 minutes ago, Cynthia Heyman said:

I've tried a Single Step

Try a script. Something like:

Set Variable [$ownerID ; Value: Owners:OwnerID ]
Go to Layout [ Dogs ]
New Record
Set Field [ Dogs::OwnerID ; $ownerID ]

If you prefer, you can pass Owners::Owner as the script parameter, and shorten the script to:

Go to Layout [ Dogs ]
New Record
Set Field [ Dogs::OwnerID ; Get (ScriptParameter) ]

 

 

 

Link to comment
Share on other sites

9 minutes ago, comment said:

Try a script. Something like:


Set Variable [$ownerID ; Value: Owners:OwnerID ]
Go to Layout [ Dogs ]
New Record
Set Field [ Dogs::OwnerID ; $ownerID ]

If you prefer, you can pass Owners::Owner as the script parameter, and shorten the script to:


Go to Layout [ Dogs ]
New Record
Set Field [ Dogs::OwnerID ; Get (ScriptParameter) ]

 

 

1

Filemaker doesn't let me type in the last line of your code....

Set Field [ Dogs::OwnerID ; Get {ScriptParameter) ]

It seems to delete it when I click off the text... how can I get it to keep the text? I'm assuming it's not letting me because it's not a premade script item.

 

Link to comment
Share on other sites

The Set Field [] script step has two parts (click the wheel icon to see them):

  • In the 'Specify target field' part, select the field used by the Dogs table as the foreign key in the relationship to the Owners table. In my example, that's Dogs::OwnerID - your table/field names may be different;
  • In the 'Calculated result' part, type:
Get (ScriptParameter)

or insert the function by double-clicking it in the functions pane.

 

Edited by comment
Link to comment
Share on other sites

Thanks for your reply, and that works! :)  I really appreciate it.

Just read over the new Card feature in Filemaker 16... and maybe I'll see if I can get that to work instead, I like that idea. 

Link to comment
Share on other sites

This topic is 2472 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.