• Resolved Kay69

    (@kay69)


    Hello,

    Suddenly in one particular calculated field, it started to add zeros to any result of two fieldnames! (example: 2*3=60)

    Other calculated fields within the same form works well.

    Kindly advise.

    Thank you.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @kay69

    Please, indicate the name of the field where the issue is happening.

    Best regards.

    Thread Starter Kay69

    (@kay69)

    Hello,

    page 6 “الارضيات الداخلية” , results field: fieldname409

    Regards,

    Plugin Author codepeople

    (@codepeople)

    Hello @kay69

    The equation in the fieldname409 field is:

    fieldname277+fieldname123+fieldname124+fieldname125+fieldname127+fieldname128+fieldname130+fieldname131+fieldname366+fieldname370+fieldname374+fieldname378+fieldname382+fieldname386+fieldname390+fieldname394+fieldname398+fieldname399+fieldname400+fieldname403+fieldname404+fieldname408

    However, in javascript the plus operator (+) is overloaded. It adds numbers or concatenate texts. If any of the operands is a text, the concatenation takes precedence. To avoid this ambiguity the plugin includes the SUM operation. You can implement the equation as follows:

    SUM(fieldname277,fieldname123,fieldname124,fieldname125,fieldname127,fieldname128,fieldname130,fieldname131,fieldname366,fieldname370,fieldname374,fieldname378,fieldname382,fieldname386,fieldname390,fieldname394,fieldname398,fieldname399,fieldname400,fieldname403,fieldname404,fieldname408)

    Best regards.

    Thread Starter Kay69

    (@kay69)

    Hello,

    The form does not work. Preview is not generated, instead a “admin.php” file downloads. We checked the data fields, could not find what’s wrong :/

    Is there a way to check, please?

    Thank you.

    Plugin Author codepeople

    (@codepeople)

    Hello @kay69

    Your form fails because you have created an endless loop.

    I’ll try to describe first how the plugin works.

    When the dynamic evaluation of the equations is enabled, each time the user edits a field’s value, the plugin checks every calculated field in the form to identify the equations affected by this value and evaluate them. However, the equations’ evaluation modifies the calculated fields’ values. So, the plugin must repeat the process until no field value varies.

    So, if a field is used in its equation it generates an endless loop. Each time the equation is evaluated it modifies the field’s value launching the equation in an endless loop.

    The same happens when field A is used in the equation of field B and field B in the equation of field A. The chain could be longer.

    You can check if there is an endless loop in your form disabling the dynamic evaluation of the equations. Please, try unticking the “Dynamically evaluate the equations associated with the calculated fields” checkbox in the “Form Settings” tab (https://resources.developers4web.com/cff/images/documentation/form-settings-tab.png)

    If you check the equation in the fieldname429, it use itself (fieldname427*fieldname429), generating the endless loop.

    Please, check the other equations in your form.

    Best regards.

    Thread Starter Kay69

    (@kay69)

    Hello,

    Understood. We corrected some typos. It is still not working.

    It’s a cumbersome process to go into each and every form. Is there a way ( a checker tool) to pinpoint such errors faster?

    Regards,

    Thread Starter Kay69

    (@kay69)

    Hello,

    Done! The “SUM” operation resloved the extra digits issue. All checked and running well.

    Thank you very much.

    Regards,

    Plugin Author codepeople

    (@codepeople)

    Hello @kay69

    Excellent !!!

    Best regards.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Calculated field adds zeros’ is closed to new replies.