Calculations do not work

Comments

5 comments

  • Rainer Grabowski

    Hi Stijn,

    I think in the first calculation there's missing an if: 

    if(@Maat boor == "16 mm" && @Aantal verdiepingen == "1 verdieping") {
    15;
    } else {
    "";
    }

    You can write it also this way: 

    @Maat boor == "16 mm" && @Aantal verdiepingen == "1 verdieping" ? 15 : ""

    I assume, the second code you need to avoid that there "null" is shown if a field is empty.The code looks correct - do you get an error notification for it too? 

    I would do it in shorter way:

    (@Voornaam + ' ' + @Tussenvoegsels + ' ' + @Achternaam).replace(/(null )|(null)/g,"")

    One tip: If you have to use the same variable token mulitple times a code you should declare it as var in the beginning, so you have to select the token only once from the popup list (this makes the code more readable and you can cope parts of it): 

    var vn = @Voornaam;
    var tv = @Tussenvoegsels;
    var an = @Achternaam;
    if(vn && tn && @an) {
    vn + ' ' + tn + ' ' + an;
    ...
    and so on 

    Here you find some rules and tips for using variables.

    Rainer

     

    1
    Comment actions Permalink
  • Henrik Huhtinen

    Well, doesn't the first one miss "if" from the beginning?

    Also, remember that calculation field's type is set by its first return. If it returns a number first, it wants to return a number. If it returns text, it wants to return text. To reset this the calculation field needs to be deleted and recreated. 

    1
    Comment actions Permalink
  • Jean-Claude Massé

    The first one, is because you don't call anything first (like if) try 

    if((@Maat boor == "16 mm" && @Aantal verdiepingen == "1 verdieping")) {
    15;
    } else {
    "";
    }

    In the second one, all your @field are compare to... nothing!

    1
    Comment actions Permalink
  • Jean-Claude Massé

    You can also use something like

    @Maat boor == "16 mm" && @Aantal verdiepingen == "1 verdieping" ? 15 : ""

    1
    Comment actions Permalink
  • Stijn

    Thanx everyone for the help and input!

     

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk