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 via a script

Featured Replies

Hello everyone,

as the topic says, I am looking at creating a new record via a script. Is this possible? I cannot seem to find the functions to do this.

Thanks so much!

All you need is the New Record script step in a script.

  • Author

yes yes I left something out :P

I want this new record function INSIDE an If statement.

sorry for leaving that out. Is that possible??

  • Author

I did try something else though but I am not sure if it will work...

If []

New Record function

End If

When doing this my first thought is it will trigger regardless because it is not inside the [], but maybe it will?

Also when doing this I found out I cannot set parameters for the new record function. I want to be able to create a new record in a different table, how can you specify that table? And set fields all in one?

Edited by Guest

If(Your Criteria)

New Record/request

EndIf

So, for example.

If(Date = Get(CurrentDate)

New Record/request

EndIf

You go to the new table first (Go to Layout), then use the New Record command.

Hi Netcode, you are getting all kinds of help here but maybe it will help to pull all the advice into one script. Let's assume you are on a customer layout of a table occurrence called Customers. And you want to create an invoice for this customer in a table called Invoices. Button to run this script should be on Customers layout:

Freeze Window

Set Variable [ $customerID ; Customers::CustomerID ]

Go To Layout [ Invoices ]

New Record/Request

Set Field [ Invoices::CustomerID ; $customerID ]

Commit Record/Request

[color:blue]...now you have a valid relationship between the two so, if there are other fields in Invoices which obtain information from Customers, such as PayMethod, you can use one of three methods:

1) set Invoice PayMethod field to be Auto-Enter (by calculation) or Lookup and specify Customers::PayMethod or

2) simply place your Customers::PayMethod field directly on your Invoice or

3) Set Field [ Invoices::PayMethod ; Customers::PayMethod ]

... then continue your script to allow User entry

Go to Field [ ...whichever Invoice field you want your User to begin entering data ]

LaRetta

  • Author

Great help everyone! I am well on the way to creating this button.

I do however have a question for LaRetta, will Freeze Window stop the current window from changing to the layout "Invoices" when the function Go To Layout is processed? If not I want to avoid changing layouts because the record creation is for a join table. Maybe i could just go to layout, then at the end of the script go back? hmmmm *me thinks*

And what exactly is the commit record function for? I did read the manual regarding that function but it doesn't make a whole lot of sense to me, maybe hearing it different might help. Something about making a new record regardless if the record can be validated? I dunno lol

Also now that I get to thinking about it when you set fields underneath a new record function I assume it sets fields for that record correct?

example

New Record/Request

Set Field

Set Field

.

.

.

Edited by Guest

Although I am not LaRetta, perhaps I can answer your question in her absence. :P

You can go back to the orig layout when you are done setting your fields. A commit record is used to force the open record to commit (you can think of save).

You may not be LaRetta but I'll bet your legs are cuter! :laugh2:

Freeze Window[] stops screen redraw. User won't see what you are doing. It will eliminate flash they would notice from changing layouts, setting fields and so forth. It will NOT stop the script from changing windows.

And what exactly is the commit record function for? I did read the manual regarding that function but it doesn't make a whole lot of sense to me,

I would suggest you jump directly to Ilyse Kazar's on "Record Ownership" in this:

http://www.filemaker.com/downloads/pdf/techbrief_fm8_migrtn_found.pdf

(Which starts at page 74)

But if we take a look at the topic as such, will you if developing a solution gradually without paying too much attention to normalization, such as adding a table here and there as demands arises. What some would characterize as suburban sprawl.

This is unfortunately a too commonly occurring scenario, due the flat learning curve filemaker have. If you then step back a little to make abstractions will you discover that ever so often are the scripting of the creation of records pretty similar to each other only really differing with the aspects.

Here can it really pay off when you eventually need to restructure the solution at hand, that the scripting gets as uniform as possible, and this can actually be accomplished via script-wrappers, so every call gets massive amount of blackbox content which can be trusted to be left out of eyesight.

Now for starters do you of course need to know the meat and potatoes of creating a record via a script, but as soon as know that by heart would I strongly suggest you use all the wrappers you can lay your hands on! Since you often can't tell how healthy your needs for script really are, the danger is often attempts to remedy a poorly structured solution.

Take a look at this:

http://web.mac.com/zueiv/iWeb/FileMaker/Script%20Killing%20Techniques/AFA363C6-2D85-4C6D-82E2-273F3722A69E.html

--sd

Edited by Guest

  • Author

Thanks for all the replies everyone! I think I got it all figured out and it seems to be working well :P

yay!

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.