• Resolved jidwictut9

    (@jidwictut9)


    Hello,

    i have added the following code in the calculated field.
    But only “operation 1” and “operation 2” are working fine. When i delete “operation 1” and “operation 2” then “operation 3” and “operation 4” are working fine. Where is the problem?

    (function(){
    /*operation 1*/
    if(fieldname18 > fieldname19) return PREC(fieldname19/fieldname18,2);
    if(fieldname18 < fieldname19) return PREC(fieldname19/fieldname18,2);
    /*operation 2*/
    if(fieldname17 > fieldname20) return PREC(fieldname20/fieldname17,2);
    if(fieldname17 < fieldname20) return PREC(fieldname20/fieldname17,2);
    /*operation 3*/
    if(fieldname18 > fieldname20) return PREC(fieldname20/fieldname18,2);
    if(fieldname18 < fieldname20) return PREC(fieldname20/fieldname18,2);
    /*operation 4*/
    if(fieldname17 > fieldname19) return PREC(fieldname19/fieldname17,2);
    if(fieldname17 < fieldname19) return PREC(fieldname19/fieldname17,2);
    })();

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

    (@codepeople)

    Hello @jidwictut9

    Thank you very much for using our plugin.

    The return instruction in the equation stops the run flow and returns the result to the field, the rest of lines of code are ignored.

    So, the only way your current equation reaches the line of code below is when the values of fieldname18 and fieldname19 are equals:

    if(fieldname17 > fieldname20) return PREC(fieldname20/fieldname17,2);

    If fieldname18 > fieldname19, the first return instruction returns the value to the calculated field, and when fieldname18 < fieldname19 happens the same with the second return instruction.

    Best regards.

    Thread Starter jidwictut9

    (@jidwictut9)

    Hello,thanks for the quick reply.

    Unfortunately I don’t know anything about JS.
    Sorry.
    I would like to solve the problem.

    Best regards

    Plugin Author codepeople

    (@codepeople)

    Hi @jidwictut9

    Please describe in detail the equation you need and I will help you to implement it.

    Best regards.

    Thread Starter jidwictut9

    (@jidwictut9)

    Hello,
    I have solved the problem in another way.
    Thank you for your help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Problem with JS in calculated field’ is closed to new replies.