foundset.refreshCalculations

Hello,

I have come across a problem, where calculations where not calculated. The setup is

Table A → Table B (1:N)
Table A → Table C (1:N)

A record is created on Table B; from there a Record in Table A is created and one or more in Table C. The problem in my setup lies in the calcs of Table C. They were not calculated. I have tried to “step” through them in a loop using getRecord without success. The only thing that currently helps is setting the field content by hand. This is, however, redudant work if you have something like calculations.

Actually, I am not asking for any changes in the way calcs are exceuted, because in earlier versions that was done too often. I would like to see a function foundset.refreshCalculations that allows me to refresh all calculations when I like. I know that there is a controller.relookup, but for that you need to access a form.

Can this be done?

Thanks
Patrick

It’s hard to follow your schema and record creation flow. Does the record created in B cause a related record in A to be created through the relationship automatically? If so, are you using that key to create a record in C linked back to the record in A? How are you writing the key and what trigger are you using when C is created to run the calcs you mention?

The whole procedure here is a bit complicate and doesn’t really matter for my feature request.

Fact is, that I walk through related records and their calculations are not updated. I can manually set the values, but that is not the idea behind calculations, is it? I have a similar problem right here: Calculations not updated - Classic Servoy - Servoy Community

Patrick

Have you looked directly at the database to see if the results of the calculations were completed regardless of what Servoy displays?

I clicked save in Servoy, switched between design and browse mode, used controller.saveData() in the method and checked the database. I am sure there is a problem, at least in my environment.

I don’t doubt there is a problem. I’m just trying to help you pin it down so the fellows will fix it up for you. This sounds more like a bug rather than a new feature. Calcs aren’t running when they should.

I do agree that a “refresh calcs” feature can be useful. I use a similar capability in Excel for optimization type calculations. It also allows you to stop calculations and run them only when you are ready for performance reasons. The default is that calcs run as expected and that’s what Servoy should do. Being able to “refresh” calcs seems like you’d also need a way to halt them. I’d prefer them to just run as expected.

Good luck!

if i could have a small example that demonstrates this behaviour i will look at it.

Also controller.relookup does the relookup of the lookup fields! It doesn’t update calculations..

That’s why this thread was titled “foundset.refreshCalculations” :)

but that is a method that i want to avoid if possible..
We just need to find a way to know for sure that the calculations are always in synch by default when loading the record.. Without the costs..

I just sent you a demo via Email. Maybe you can have a look at that, but I think anyone can produce a case that shows this problem.

i changed the behaviour now that when a record is taken from the database all the stored calculations are checked (and stored if changed)
So now only one loop of the foundset is needed. No need to touch or to display it on screen.

a simple loop over the foundset will update everything

for(var i=1;i<=foundset.getSize(); i++)
{
foundset.getRecord(i)
}