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.

Newbie question re:setfield[]

Featured Replies

Hi all,

Newbie here again.

I created 2 files(.fp7), first file contains records while the second file has empty records.

Second file will be used as a portal

Both Files are related, (file1::pin) have records and i want to copy each record to (file2::pin) whenever i add new records to (file2).

Can I use setfield[] and whats the syntax for this?

Thanks in advance.

Well no... you would most likely trigger a script in the other file to import the current record your on... theres problems with this though.

Before you go do any of that though, a) why are you replicating data : is there any particular reason you are using 2 files?

  • Author

Hi Genx,

I made a new file because file1 contains records already.

The file2 will be used as a portal in file1. I was thinking that if i did it this way I can add new record to file2.

---------------------------------------------

file1----------file2

pin-----------pin-------rank------vessel

10000--------10000-----MS-------RORO

--------------10000-----BS--------NSTY

--------------10000-----WS--------WKMV

----------------------------------------------

file1 contains pin already, while file2 pin is empty

need to connect file1::pin to file2::pin, so I can see the records

of file2-records to file1.

I dont know the script for make new record for just a portal.

Thanks

Edited by Guest

A) You really don't need 2 files, and in this case, you might be making life more complicated for yourself if you use two files - multiple files were only mandatory prior to FM7, since then, you can have many tables in one file.

Basic relational structure will work as follows:

Main Table:

PrimaryID (or pin in your case, if you can guarrantee uniqueness)

Name

Address

Contact Numbers:

ForeignID

Number

If i wanted to create many contact numbers for one contact, i would relate: Main Table To Contact Numbers by dragging from PrimaryID to ForeignID.

Then, Double click on the newly formed relationship, and on the child side (Contact Numbers) click the option "Allow creation of records in this table based on this relationship".

Then, If you base your main layout on the Main Table, created a portal to the Contact Numbers, based on the relationship we specified, you will get a "ghost record" appear as the bottom row in your portal -- allowing you to add records without duplicating data anywhere.

Confusing? - better to be confused now then sorry later

  • Author

Hi again Genx,

I grasp the concept of Primary key and foreign key, but on may Main layout I want to click a button to open up another window of layout and instead of editing the portal at the main menu-portal in main menu will be for viewing only.

On the New Window it will be for editng of the portal, but instead of portal I will use fields.

The user will click a button on the new window and save the data, then the field must be empty again for another data to be entered. So, I need something like (Add record to portal row) to be attached to my Save Button.

And yes your right I'll make another table instead of making another File (what was I thinking!!!).

Thanks a lot

Well, no, you should "pre-generate" the record, that is... Save the primary key of the current record as a variable.. open your window, go to your secondary table, set the foreign key as the stored variable -- you have a related record e.g.

Set Variable[$key ; MainTable::PrimaryKey]

New Window[]

Go To Layout[some Layout Tacked on to Secondary Table]

Set Field[secondaryTable::ForeignKey ; $key]

Commit record[]

  • Author

Wow, that was great.

Now I need a Button to make a new record for the second table only.

I tried to use (New Record/Request) but, all it did was make a new record for all related tables.

Table1::PIN--Table2::KP_PIN---NAME

10001--------10001-----REX-----Click button New rec

>>>>>--------10001------ROY-----Click button

>>>>>--------10001-------SOY-----Click button

and so on................

Thanks again.

Edited by Guest

You have to be on a layout relating the the second table -- not the first table.

e.g. i actually forgot to put new record / request in there.. oops

Set Variable[$key ; MainTable::PrimaryKey]

New Window[]

Go To Layout[some Layout Tacked on to Secondary Table]

New Record / Request[]

Set Field[secondaryTable::ForeignKey ; $key]

Commit record[]

  • Author

I got it to work, but I need to go to next record also and clear the field.

My first table is duplicating, I think it because of the New Record[]

thanks again

Edited by Guest

Well yes, but like i said, you have to be on a layout connected to your secondary table when you perform the new record script step -- otherwise, it generates a new record in your primary table instead.

  • Author

I'M OK NOW

Do you know any site that can help me start with scripting....very very newbie.

Thanks for the help Sir Genx

Oooh sir genx, isn't that nice.

No i don't really know a lot of good sites for this -- all i can really recommend is the FileMaker manual.

In the end - it just comes to which functions you use - which comes to which functions you know...

Just start - and you'll get better.

... That or go buy a scripting book - might be worth the investment.

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.