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.

Set Variable, go to, check duplicates and set field...

Featured Replies

Hi. New here, nice to meet you all. Ive got a small problem you might be able to help with.

I need to move data from one related table to another (to keep the old data if we change the original data). And I have made a script that works fine. But I would like to add a if "Protokoll register::ProtPunktID FK" exist within the related results (Protokoll::Prot ID) skip "Set field" steps.

Should I use a go to find mode and perform find, or what is the smartest way? How do I then make it search on a variable like $Protokoll for example?

Set Variable [ $Protokoll; Value:Protokoll::Prot ID ]

Go to Related Record [ From table: “Protokoll register”; Using layout: “Rapport protokoll register” (Protokoll register) ] [ Show only related records ]

Go to Record/Request/Page [ First ]

Freeze Window

Loop

Set Variable [ $Namn; Value:Protokoll register::Namn ]

Set Variable [ $ProtpunktID; Value:Protokoll register::ProtPunktID ]

Set Variable [ $Gruppering; Value:Protokoll register::Protokoll Grupp ]

Go to Layout [ “Protokoll Line” (Protokoll Line) ]

// Here I would like to check if it exist any record with "Prot ID=$Protokoll" and "Protokoll register=ProtPunktID" in this table. Then I can just skip the next steps with "if" command.

New Record/Request

Set Field [ Protokoll Line::ProtPunktID FK; $ProtpunktID ]

Set Field [ Protokoll Line::Namn; $Namn ]

Set Field [ Protokoll Line::Protokoll Grupp; $Gruppering ]

Set Field [ Protokoll Line::Prot IDfk; $Protokoll ]

Commit Records/Requests [ Skip data entry validation; No dialog ]

Go to Layout [ “Rapport protokoll register” (Protokoll register) ]

Go to Record/Request/Page

[ Next; Exit after last ]

End Loop

Go to Layout [ “Protokoll” (Protokoll) ]

Many thanks for any tips.

If I understand this correctly, importing the records would be more suitable. You can set the ID field in the target table to validate as Unique, Validate always. This will prevent importing duplicate records.

  • Author

Aha. Ive never tried that. But that does not take in count what records are related right? I only want to copy certain specific records that are related to the first table. And I also need it to work on the web so I figure this is the only way...

If the file is open, only the found set in the source table will be imported. IOW, do a find, then import. I think this should work in IWP too, but I haven't tested it.

  • Author

Thanks, but that still leaves me with the first problem. if I run the script two times, it still create duplicates containing the same data.

I want it to check the records, and only import those ones that is missing/not represented in the table (hence the first question)... And then make the record unique thou the related "protIDfk" field.

Any more tips?

Perhaps I don't understand the context here. If you define some field to validate as Unique, Validate always. then Filemaker will not allow importing a record with a value that already exists in the table.

  • 2 weeks later...
  • Author

Does the unique value only validate within in the current find? Otherwise its no good because there is no uniqe value to work with, only a combination of two field values that together must be unique.

Oh, now when im writing this it hits me that I could make a calc field, combine two fields and use that as a unique value. Ill give that a go. thanks.

You cannot validate a calculation field - but you could use a field with auto-entered calculated result instead.

  • 2 weeks later...
  • Author

Hi again.

After some testing I found that the import works brilliant. Many thanks for the tips. I just go to related, and then import. The validation with auto-entered calculated result is perfect.

again, many thanks...

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.