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 value with calculated field name

Featured Replies

Hi,

I'm trying to set a values to calculated field names and these fields are not in the Layout, so I can't navigated through them.


SetVariable[$fieldPrefix; "img"]

SetVariable[$linkPrefix; "txt"]

SetVariable[$firstFieldName; Get(ActiveFieldName)]

SetVariable[$fieldName; $firstFieldName]

Loop

  if (PatternCount($fieldName; $fieldPrefix) > 0)

    SetField[Abase:$linkPrefix & $fieldName; $XYZvalue]  // This is what I'm trying to figure out

  end if

  Go to Next Field

  SetVariable[$fieldName; Get (ActiveFieldName)]

  Exit Loop If ($fieldName = $firstFieldName)

End Loop

The purpose is that each container is paired with a text field which contains a URL to a web image.

So is there a way to programmatically set the value of a calculated field name? or a workaround?

Exactly I want something like:

[color:red]Set Field[TableName::$fieldName; $value]

Thank you

FileMaker can't set fields by variables, but you can work around it using named objects. Look at the Main page of these forums, there's an article there entitled "Set Fields by Indirection!"

  • Author

Yes, I know I checked the page, the problem is that I use FMP 8 Advanced and the function is for 8.5...

You can do it with versions back as far as 5 (or possibly earlier) if you use the kludgy method of putting a go to next field inside a loop and checking the active field name after each iteration. As for them not being on the current layout, you just have to create a utility layout with the fields on it, and have your script go to that layout first.

However, I had recent thought about doing this a different way which I think is a lot cleaner, although it requires setting up the autoenter option of any fields that you want to set indirectly. See attached file.

SetFieldIndirect.fp7.zip

  • Author

I worked around displaying the fields on the layout and making them invisible.

But concerning your solution and since I'm new to FM, how the Let function works? I've tried to understand, but couldn't figured how it works. And why do I see sometimes a kind of a bold "P" characters, what is the use of this one?

Thank you

The Let() function allows you to define temporary variables within a calculation. It is useful if you need to use an intermediate result in several places. I used it in the example so that when you paste the formula into a new field auto-enter calculation, you only have to change a single field name.

The ¶ symbol is interpreted by Filemaker as a line break. Line breaks are used to separate items in a value list.

The script simply sets a global field to a two element value list. The first element is the name of the field to be set, and the second element is the data. The auto-enter formula uses LeftValues(gIndirectSetField;1) to get the field name, and RightValues(gIndirectSetField;1) to get the data. If the field name matches it's own, then its old data is replaced with the new data.

  • Author

Thanks very much! I now have a new way to work around indirection!

Nick

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.