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.

Make calculated value act like field name

Featured Replies

I want to create a batch testing script and test 300+ fields. So, in this example, I will be testing how the data in field calc::avg_vol is performing, so I will try to replace field contents from field calc::avg_vol to calc::temp_field. I don't want to write a Replace Field Contents script for each of 300+ fields. Instead, I came across with such an idea:

Put field names into separate field and then put it to a variable, like this:
1) Go to Layout (Fields)
2) Set variable ($Name; fields::name) (e.g. calc::avg_vol)
3) Go to Layout (calc)
4) Replace Field Contents (calc::temp_field; $Name)

But the problem here is that it treats "calc::avg_vol" like a text instead of putting actual data from calc::avg_vol, it just prints "calc::avg_vol" text.

So how could I get the contents of calc::avg_vol to calc::temp_field? (I want this as scripted or as automatic as possible, because any manual intervention slows the whole process down)

Edited by UltraNIX

10 minutes ago, UltraNIX said:

I want to create a batch testing script and test 300+ fields. So, in this example, I will be testing how the data in field calc::avg_vol is performing, so I will try to replace field contents from field calc::avg_vol to calc::temp_field. I don't want to write a Replace Field Contents script for each of 300+ fields. Instead, I came across with such an idea:

Put field names into separate field and then put it to a variable, like this:
1) Go to Layout (Fields)
2) Set variable ($Name; fields::name) (e.g. calc::avg_vol)
3) Go to Layout (calc)
4) Replace Field Contents (calc::temp_field; $Field)

But the problem here is that it treats "calc::avg_vol" like a text instead of putting actual data from calc::avg_vol, it just prints "calc::avg_vol" text.

So how could I get the contents of calc::avg_vol to calc::temp_field? (I want this as scripted or as automatic as possible, because any manual intervention slows the whole process down)

instead of step 4, please try "Set Field" script step and see if it works.

  • Author

I need to replace field contents in all of the 14000+ records in the table, so looping through it all with set field would be painful.

Just now, UltraNIX said:

I need to replace field contents in all of the 14000+ records in the table, so looping through it all with set field would be painful.

What is the field type in step 2?

  • Author

Text

try :

 

Set variable ($Name; getastext(fields::name) )

Edited by siroos12

  • Author

Nope, didn't help :(

on step 4, shouldn't it be  $Name instead of  $Field ? as you are setting the variable to be called  $Name .

  • Author

It's just a typo. In a script those values match.

Please check attached file. You type in your words in cell "a" in table "A" , then run the script.

test.fmp12

3 hours ago, UltraNIX said:

I don't want to write a Replace Field Contents script for each of 300+ fields.

The target field for Replace Field Contents[] cannot be calculated. If you want to loop over multiple fields, you can place them on a layout, make sure all of them - and only them - are included in the layout's tab order, and loop over them using Go to Next Field (comparing the current field's name with the first field's name for the exit condition). Then use Replace Field Contents[] without specifying the target field.

Alternatively, you could use the Set Field By Name[] step - and add an outer loop to go over the 1400+ records in the table.

There probably is a better approach to whatever you seem to be doing here overall. If you have 300+ separate fields that need to be treated alike, it is very likely you should have 300+ individual records (for each one of the 14000+ records in the table) in a related table instead.

 

Edited by comment

  • Author
5 hours ago, siroos12 said:

Please check attached file. You type in your words in cell "a" in table "A" , then run the script.

test.fmp12

Thank you for your input. It's not exactly what I was searching for, but as others already pointed out - there's no way to solve this problem with REplace field contents. So I will have to go out with Set Field by name and Loop through all records.

1 hour ago, UltraNIX said:

as others already pointed out - there's no way to solve this problem with REplace field contents

That's not what I said.

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.