# Calculated Custom Field Not working in V19

**URL:** <https://www.dolibarr.org/forum/t/calculated-custom-field-not-working-in-v19/25001>\
**Category:** Using my Dolibarr\
**Created:** [February 22, 2024, 11:23am UTC](https://www.dolibarr.org/forum/t/calculated-custom-field-not-working-in-v19/25001 "2024-02-22T11:23:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rommelngo](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/r/779978/32.png) [@rommelngo](https://www.dolibarr.org/forum/u/rommelngo)\
**Post date:** [February 22, 2024, 11:23am UTC](https://www.dolibarr.org/forum/t/calculated-custom-field-not-working-in-v19/25001/1 "2024-02-22T11:23:43Z")

</div>

I just notice that my instance is now in v19 (which by the way I couldn’t find the setting that made it to automatically upgrade to the latest version, I would like to turn that off so that next time I can pick the time I wish to upgrade and perhaps do a backup first before doing so so that I can easily revert back)

Suddenly all my calculated fields are having some problems

 ![image](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/6/61fb6f465388e713364d84d19084866c4a4855d3.png)  
Bad string syntax to evaluate (found call of a function or method without using direct name): ((($reloadedobj = new Product($db)) && ($reloadedobj-\>fetchNoCompute($objectoffield-\>fk\_product) \> 0)) ? $reloadedobj-\>array\_options[‘options\_pcsperbag’] : ‘0’)

my exact fomrula is:  
((($reloadedobj = new Product($db)) && ($reloadedobj-\>fetchNoCompute($objectoffield-\>fk\_product) \> 0)) ? $reloadedobj-\>array\_options[‘options\_pcsperbag’] : ‘0’)

 ![image](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/e/ebc9935ad1b6744b1bea92101cf27ab387223c1b.png)

it was working fine before and in fact I have another sandbox which is still in v18 with the same formula and have no problems

 ![image](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/2/2892ba5b539905a2690539ab872663e45f145ec2.png)

Can anyone please help?

---

<div class="post-metadata">

**Author:** ![gwilhom](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/g/f1d935/32.png) [@gwilhom](https://www.dolibarr.org/forum/u/gwilhom)\
**Post date:** [July 30, 2024, 9:11am UTC](https://www.dolibarr.org/forum/t/calculated-custom-field-not-working-in-v19/25001/2 "2024-07-30T09:11:03Z")

</div>

Hi there,

same issue here since the V19. It is a un-documented regression and I did not find a working fix for now w/o digging to the underlying dolibarr code.

As soon as I had relative complex formula (in my case simply substracting a date custom field with the current date to find an age…) with an if condition (?) it does throw the same error as you have.

After hours of working I finally ended up to remove the if condition (?) and it does work, however with a regression as if the custom date field is not filled in, the end-user will see the current year (a bit ugly).

For info, my formula \>\>

dol\_print\_date(dol\_now(), ‘Y’) - dol\_print\_date($object-\>array\_options[‘options\_bpdateofbirth’], ‘Y’)

PS : I tried all sort of () to isolate variables, etc w/o success. I had to revert back to this very simple formula…

---

<div class="post-metadata">

**Author:** ![rommelngo](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/r/779978/32.png) [@rommelngo](https://www.dolibarr.org/forum/u/rommelngo)\
**Post date:** [July 30, 2024, 9:27am UTC](https://www.dolibarr.org/forum/t/calculated-custom-field-not-working-in-v19/25001/3 "2024-07-30T09:27:37Z")

</div>

i did manage to fix my formula.

($reloadedobj = new Product($db)) && ($reloadedobj-\>fetchNoCompute($objectoffield-\>fk\_product) \> 0) ? $reloadedobj-\>array\_options[“options\_pcsperbag”] : 0

from  
((($reloadedobj = new Product($db)) && ($reloadedobj-\>fetchNoCompute($objectoffield-\>fk\_product) \> 0)) ? $reloadedobj-\>array\_options[‘options\_pcsperbag’] : ‘0’)

think it was with the unnecessary parenthesis maybe. not sure, but you can compare the two formulas
