Skip 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.

creating a new record in new layout

Featured Replies

Hi

 

I have 1 layout (customers) with customer details in it,

 

but i want to place a button on (customers) layout that would take me to layout 2 (invoices)

 

and insert the same customer id as well as create a new invoice id record

 

i already have 

 

Customers table field name  __pkCutomersID

 

Invoices table field name __pkInvoiceID  & _fkCutomersID related to __pkCutomersID

 

i have tried many ways but with no luck

 

Thank you all in advance

If the relationship from customers to invoices has create turned on in Invoices a script that sets any field in the Invoices table from the context of Customers will create a new Invoice record if none are present.

 

So if in your script you setfield Invoice::_fkCustomerID = Customers::__pkCustomersID a new invoice will be created IF their are not already matching records.

 

if their ARE matching records then you wil be EDITING the (first by relationship sort order i think) matching Invoice for the Customer

Assuming that after creating a new invoice for the customer, you want to start editing it in on the Invoices layout* – enter the date, add line items etc. – the basic approach is …

(on the Customers layout)
Set Variable [ $customerID ; Customers::__pkCustomerID ]
Go to Layout [ Invoices ]
New Record/Request
Set Field [ Invoices::_fkCustomerID ; $customerID ]
# end script; start editing your new invoice 

Add the usual sanity checks to the beginning of the script; e.g. if the found set is empty, exit the script and do nothing.

 

*as opposed to scenarios where you can edit/configure the related records conveniently in a portal on the parent layout; so you would create a new record, then remain on / return to the parent layout

  • Author

thanks for trying to help but im stuck i need more baby steps please

 

i create a button then?

1.  On the Scripts menu, go to Manage Scripts.

2.  Bottom left hand corner, click new.

3.  Use the script Eos provided, Changing field names and layout names to match your DB.

4.  Save Script.

 

5.  Go to the layout you want to invoke the script, enter Layout mode.

6.  From the toolbar, click the Button Tool.

7.  Draw the button on the layout, the button menu pops up.

8.  Click Perform Script, then to the right click Specify.

9.  Pick the Script you just wrote, Click ok (close the window), click ok, close the window.

10.  Now you're back on the layout with a blinking cursor, type what you want on the button (you can add a tooltip from the inspector if you want.

11. Save and go back to Browse Mode.

  • Author

thanks for your help but im missing a step i think

 

1.  On the Scripts menu, go to Manage Scripts.   All OK

2.  Bottom left hand corner, click new.  All OK

3.  Use the script Eos provided, Changing field names and layout names to match your DB.  Stuck

4.  Save Script.

 

im stuck at step 3 when i click new i get a pop up that wont let me paste on what Eos provided i have to choose from the menu on the left 

Control

Perform script  is what i select then im asked to specify script  which i do then when i paste Eos script i get errors like the specified table cannot be found which is Set Variable highlighted

You really cant copy/paste in this situations. You have to click the script steps from the left, and put in the proper parameters.

For example when you double click 'Set Variable' on the left, Set Variable pops up on the right. Then in the bottom right you see buttons you click where you enter $customerID, etc. You don't type in all the punctuation, FM puts them in for you.

I strongly recommend you grab a copy of The Missing Manual.... or the FileMaker Training Series and follow along the sample files. I jumped into my first database, realized it was very confusing. Then I went through both of those books, as well as other reference materials. It helped a lot. You want to learn as much as you can before you get too far down a possible wrong path then realize you have to start over.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.