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.

Add new record from Portal via Button

Featured Replies

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?

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.

  • Author

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

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.