AnsweredAssumed Answered

Error saving decimal fields in custom code

Question asked by jlabuelo on Jul 18, 2017
Latest reply on Jul 18, 2017 by André Lopes

Hello

Let me show you the issue we are having in a custom logic_hook when we try to save a field of type decimal in our custom code.

We have an external custom bean in the logic hook (from another module I mean) called $bean1, which has a field callded total_c of type decimal.

In the logic_hook of the module, we create a "before save" hook that would add the field $bean1->total_c to another field of type decimal

$hook_bean->number_c = $bean1->total_c;

However after the code ends, all the values in the $hook_bean->number_c are incremented by 100. So for example if

$bean1->total_c = 2.2;

$hook_bean->number_c = $bean1->total_c;

Then the value stored in the $hook_bean->number_c after the "before save" action of the hook ends, it is "220" instead of "2.2". In the screen the value of the field (Detail View, List View...) is 220, and also in the DB, but it should be "2.2".

 

Did anyone faced this problem before?, Any suggestions to face this issue?

Our version is SugarCRM CE 6.5

 

Regards!!

Outcomes