# Calculations

**URL:** <https://forum.servoy.com/t/calculations/11563>\
**Category:** Classic Servoy\
**Created:** [January 5, 2010, 9:58am UTC](https://forum.servoy.com/t/calculations/11563 "2010-01-05T09:58:57Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hans\_Nieuwenhuis](https://avatars.discourse-cdn.com/v4/letter/h/87869e/32.png) [@Hans\_Nieuwenhuis](https://forum.servoy.com/u/Hans_Nieuwenhuis)\
**Post date:** [January 5, 2010, 9:58am UTC](https://forum.servoy.com/t/calculations/11563/1 "2010-01-05T09:58:57Z")

</div>

Hi,

I am using unstored calculations.  
I have parent records with children wich als can have children, so 3 levels deep.

I copy the complete 3 levels using databaseManager.copyMatchingColumns.

I do not use autosave.

In 3.5.x and 4.x when I duplicate and then save and commit, all the calculations are done and the result is oke.

in 5.0.1 the calculations are not executed !!!, but when i stop/start the application, the calculations  
are executed and everything looks oke.

QUESTION : Has there been a change in the way calculations are triggered in 5.x ???

Regards,

Hans Nieuwenhuis

---

<div class="post-metadata">

**Author:** ![Hans\_Nieuwenhuis](https://avatars.discourse-cdn.com/v4/letter/h/87869e/32.png) [@Hans\_Nieuwenhuis](https://forum.servoy.com/u/Hans_Nieuwenhuis)\
**Post date:** [January 5, 2010, 11:00am UTC](https://forum.servoy.com/t/calculations/11563/2 "2010-01-05T11:00:48Z")

</div>

Hi,

did some further investigation.

It looks like the Commit/Save does not trigger the unstored calculations in 5.x ( it does in 4.x en 3.5.x)

Can one of the Servoyans reply on this issue ??

Regards,

Hans

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [January 5, 2010, 11:10am UTC](https://forum.servoy.com/t/calculations/11563/3 "2010-01-05T11:10:19Z")

</div>

Hans,

Triggering of calculations has changed in Servoy 5, the number of times that all calculations were invalidated is reduced by keeping better track of which calcs depend on which data.

Can you create a small sample solution that shows this?

Rob

---

<div class="post-metadata">

**Author:** ![Hans\_Nieuwenhuis](https://avatars.discourse-cdn.com/v4/letter/h/87869e/32.png) [@Hans\_Nieuwenhuis](https://forum.servoy.com/u/Hans_Nieuwenhuis)\
**Post date:** [January 5, 2010, 11:29am UTC](https://forum.servoy.com/t/calculations/11563/4 "2010-01-05T11:29:25Z")

</div>

Rob,

Thanks for your quick response.  
I’ll give it a try and get back on this.

But I think it is very simple, in 3.5.x and 4.x the unstored calculations where fired on a committransaction/savadata.  
In 5.x they do not get fired on the same event.

Regards,

Hans

---

<div class="post-metadata">

**Author:** ![Hans\_Nieuwenhuis](https://avatars.discourse-cdn.com/v4/letter/h/87869e/32.png) [@Hans\_Nieuwenhuis](https://forum.servoy.com/u/Hans_Nieuwenhuis)\
**Post date:** [January 5, 2010, 4:19pm UTC](https://forum.servoy.com/t/calculations/11563/5 "2010-01-05T16:19:55Z")

</div>

Hi Rob,

I managed to create a sample solution that gives a problem simular to mine.

Import this solution into 4.x and then :

- start solution
- make sure that parent id 1 is active (should be oke)
- hit the duplicate button
- the parent, childs and subchilds are now copied
- several calculated fields are now 0
- hit the save button and the calculations are all fired and are correct !!!  
The totprijs in the top form should be 1946 and it is.

Import this solution into 5.x and then :

- start solution
- make sure that parent id 1 is active (should be oke)
- hit the duplicate button
- the parent, childs and subchilds are now copied ( note the new id in the topform )
- some calculations are fired immediately, but they give the worng answer ( Totprijs in top form should be 1946 )
- now hit the save button, notthing changes. Still wrong value(s)
- now start and stop the solution and go to the record you created.  
now the Totprijs in the top form should is 1946 as it should be

This is VERY important to us, because we use this al over the place.  
And it stops us from going to 5.x

I am also looking into doing a recalc when saving, but this is rather complex.

Please advice.

Regards,

Hans

[calcsave.servoy](https://forum.servoy.com/uploads/short-url/k8Q6Nk13pQO8YKGlF4f5vFvbvyb.servoy) (8.43 KB)

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [January 5, 2010, 8:26pm UTC](https://forum.servoy.com/t/calculations/11563/6 "2010-01-05T20:26:31Z")

</div>

Hans,

This has already been fixed in the next Servoy version (5.1).  
It works even better now, the calculation values are correct even before saving.

Expect the first beta of 5.1 early this year.

Rob

---

<div class="post-metadata">

**Author:** ![Hans\_Nieuwenhuis](https://avatars.discourse-cdn.com/v4/letter/h/87869e/32.png) [@Hans\_Nieuwenhuis](https://forum.servoy.com/u/Hans_Nieuwenhuis)\
**Post date:** [January 5, 2010, 8:32pm UTC](https://forum.servoy.com/t/calculations/11563/7 "2010-01-05T20:32:32Z")

</div>

Great news Rob,

Servoy keeps surprising me with there increasing quality and speed of development and bug-fixing !!!

Regards,

Hans Nieuwenhuis

---

<div class="post-metadata">

**Author:** ![lwjwillemsen](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/lwjwillemsen/32/4987_2.png) [@lwjwillemsen](https://forum.servoy.com/u/lwjwillemsen)\
**Post date:** [January 6, 2010, 1:12pm UTC](https://forum.servoy.com/t/calculations/11563/8 "2010-01-06T13:12:18Z")

</div>

Hello Hans and Rob,

It wonders me why you are so happy about the speed of this bug-fix Hans (early 2010 ?)

I have quite a bit of inconvenience of this bug.

The situation is that the bug is introduced in v5.0 and v5.0 is no longer in beta-stage…

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [January 6, 2010, 1:42pm UTC](https://forum.servoy.com/t/calculations/11563/9 "2010-01-06T13:42:50Z")

</div>

Hi lambert,

did you report this to Servoy in there system, and make a sample case?

---

<div class="post-metadata">

**Author:** ![lwjwillemsen](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/lwjwillemsen/32/4987_2.png) [@lwjwillemsen](https://forum.servoy.com/u/lwjwillemsen)\
**Post date:** [January 6, 2010, 2:01pm UTC](https://forum.servoy.com/t/calculations/11563/10 "2010-01-06T14:01:55Z")

</div>

Hi Harjo,

It’s already fixed says Rob but we have to wait till early 2010 ![:(]( "Sad")

For now I issue _databaseManager.recalculate(foundset.getRecord(foundset.getSelectedIndex()))_ in several of my forms onPostSave triggers…

---

<div class="post-metadata">

**Author:** ![Hans\_Nieuwenhuis](https://avatars.discourse-cdn.com/v4/letter/h/87869e/32.png) [@Hans\_Nieuwenhuis](https://forum.servoy.com/u/Hans_Nieuwenhuis)\
**Post date:** [January 6, 2010, 2:25pm UTC](https://forum.servoy.com/t/calculations/11563/11 "2010-01-06T14:25:51Z")

</div>

Hi,

It is almost early 2010, is’nt it ? ![;-)]( "Wink")

Regards,
