Announcement

Collapse
No announcement yet.

Formulas - Multiplying a value by -1 always gives back -1 as an answer.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Formulas - Multiplying a value by -1 always gives back -1 as an answer.

    In a formula, if you multiply a value by a negative number, the answer is always the negative number you used.

    $value= (20 * -10);
    output\printLine($value);​

    Returns -10;

    $value= (20 * -1);
    output\printLine($value);​

    Returns -1;

    Do other people get this too? Confirm it in the Formula Sandbox.

    Version 8.2.2​

  • #2
    Use parentheses. * (-10)
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment


    • #3
      I think we had a similar bug report about this.

      Use this as workaround:

      $value= (20 * (-10));
      output\printLine($value);​

      Comment


      • #4
        these work both

        [your field] = -(20*10)

        [your field]= 20*(-10);​

        Comment

        Working...
        X