Jump to content

How to use a global variable within a calcualtion field


This topic is 2442 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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!

 

Link to comment
Share on other sites

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,

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This topic is 2442 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.