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

For Loop in a Calculation?

Featured Replies

I have a table with contact information for customers

And i have a table for open service tickets.

The fields are related by company.

I have a button to send an email internally to announce the new ticket.

I want the ticket to include the email addresses of all related contacts (related by company)

Now I could use

Count ( Contacts::EmailAddress)

for an If statement, to determine if there are more than one contact records for that customer

And i could use GetNthRecord ( Contacts::EmailAddress; 2)

But what i want to know, is there any way to do a For Loop?

Like

For( TempVar; Start at 1; end at Count ( Contacts::EmailAddress);

GetNthRecord ( Contacts::EmailAddress; TempVar)

)

I know there is no for loop, but how can i do a conditional loop that doesn't force me to copy the same code over and over and change the numbers for each repetition

It just seems so inefficient to me.

Thanks in advance!

It would be really easy to do with the List function if you had FileMaker 8.5:

List(Contacts::EmailAddress)

If you want to use GetNthRecord, you'll need FileMaker Advanced to create a recursive custom function.

GatherRecords (Field; Found) =

Case(

Found > 1;

GetNthRecord(Field; Found) & "¶" & GatherRecords(Field; Found - 1);

GetNthRecord(Field; 1)

)

Once you have the recursive custom function, you can call it in a calculation using the following:

GatherRecords (Contacts::EmailAddress; Count(Contacts::EmailAddress))

1. Same as here.

2. You can also define a value list of e-mail addresses (only related values) and use ValueListItems() to get the values.

Edited by Guest

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.