Jump to content
Server Maintenance This Week. ×

Add new record from Portal via Button


danielrmitchell

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

Recommended Posts

Add New Record Button

 

I have a portal on my Customer layout to display essential details of a customers Devices.  Currently I can a new Device for a customer using the following method:

  1. Go to the last Portal Row
  2. Select a DevceType from a dropdown list (this creates a new record in the Devices table)
  3. I then click on a button (Edit) which takes me to the newly created record, now linked to the Customer table
  4. I then edit the Device record in full

I would instead prefer to have a Add Device button:

  1. Click add device
  2. This creates a new record related to the customer from where I clicked the button
  3. Edit the Device record in full.

In this manner I can then have the portal rows changed to summary fields and be no longer editable.

 

I hope this all makes sense?

 

When I create a Add Device button I set it to Perform a script as follows:

  1. Got to Portal Row [select; Last]
  2. Set Field [Device::__pkDeviceID]
  3. Go to Related Record [show only related records; From table "Device" using layout "Device" (Device)]

The problem is that, although it all seems right in my head, it seems to do absolutely nothing whatsoever!

 

Any ideas?

Link to comment
Share on other sites

Hi Daniel,

 

If you wish to remove the 'allow creation of related' from the portal so new Device records are created by a button above the portal, it would be handled via button script similar to:

 

Set Variable [ $customerID ; Customers::CustomerID ]

Freeze Window

Go To Layout [ your Devices data-entry layout based upon Devices table ]

New Record/Request

Set Field [ Devices::CustomerID ; $customerID ]

Go To Field [ your first data-entry field ] ... this is optional of course

 

In your current example above, you were setting the Device::__pkDeviceID but you do not set this field - it fills in automatically when you set any other field in Devices.  So if you have 'allow creation on' to a portal, always turn off entry to the portal's primary key (Device::__pkDeviceID) or do not include it in the portal at all.  When someone types data into a regular Device field in the portal row, FileMaker graciously inserts the CustomerID into the Devices record all by itself.  The first time I saw this happen, I thought it was magic!!

 

So back to the New Device button ... place it above the portal, remove 'allow creation' from the relationship (in the graph) and attach the above script and see if that gives you what you expect.  Let us know if it needs adjusting.

  • Like 1
Link to comment
Share on other sites

Thank you again LaRetta.

I can see how your solution works where mine failed, and I can see it's magic as you say.

Initially I had a little issue implementing your script "Set Field [ Devices::CustomerID ; $customerID ]" as I could not see where or how to enter the variable, but it all makes sense now.

 

The next step though, and I think it is related enough to include in this same thread, is how do I reverse this so that once data entry is complete on the Device layout so that I can have a button to take me back to that customer layout?

 

I am guessing that a scripted button will be needed and that same %CustomerID variable will be used?

 

No worries, no script needed, just Go to Layout... sorted!

Edited by danielrmitchell
Link to comment
Share on other sites

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