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.

How to use a global variable within a calcualtion field

Featured Replies

Hi,

I have a global variable that has been set from previous a script. This global variable is $$abc and has a value of 100.

I have two fields on Table A, Field1 and Field2. Field 1 has a value of abc, and field 2 is a calculation field with this formula: (Evaluate ( "$$" & Field1 ) ). The calculated result, in this case, should be "100" since that is the value of the Global Variable that I have set on the previous Script.

However, I don't know what I am doing wrong. I Evaluate the formula on data viewer and it evaluates it correctly, but on the calculation field, it is just not working. I have tried to set the formula as $$abc directly, and still, it does not perform the calculation on the field.

Any ideas would be much appreciated.

Thanks a lot in advance for your time.

 

Hi,

I just solved the problem, it seems that calculation needs to be set to not store calculation results.

Thanks a lot for just reading this!

 

Reconsider having a calc field that is based on a global variables.  Or any kind of variable.  It would recalculate for all visible records in the found set so: why? 

 

 

  • Author

Wim,

Many thanks for your comment.

I am still a newbie, and this solution is meant for a small family business that rent out apartments for holidays. My solution is a booking engine. There is a check in date and check out date and when you write those, a portal shows which apartments are available, but it didn't show the price for those dates. What my script does is to disintegrate the date ranges into each day as a record on another table. Then each day is loop into the season tariffs table to check whether it falls into the date range of a specific tariff (each season is a record) when it finds it, it gets the price per day. Then I get a field to summarize all prices per day for that booking, and that is the price that it is passed through as a global variable to another table just before I completely delete all individual days records so I can make a new inquiry afterward. Then on the apartments Table, I do the calculation to show the $$totalbookingcost and show if the apartment is ready for those dates.

If my explanation of the process was clear enough, would you suggest a simpler approach to not use the calc field to be based on a global variable? I know this process may seem complicated but I couldn't come up with any other solution :(Right now the solution is working perfectly, but I am craving to learn more and more Filemaker approaches since I am so passionate about learning new programming skills!

Thanks a lot in advance,

5 hours ago, docasar said:

Then I get a field to summarize all prices per day for that booking, and that is the price that it is passed through as a global variable to another table just before I completely delete all individual days records so I can make a new inquiry afterward

This piece does not sound right.  I would probably want to keep all the inquiries and set the price statically through a script instead of relying on calculated fields.  Any calculations can be done in the script and the result stored.

 

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.