What's wrong with this formula (multiple if's)?
Good evening, I've been trying to have a calculation give a result depending of which options a user selects (A, B, C or a combination). However, the below formula gives the following error message: "Script error: TypeError: cannot read property 'sort' of null" Could someone help out :)? Thanks a lot, Alex if (@Activation == "A") { 10000 } else if (@Activation == "B") { 5000 } else if(@Activation == "C") { 10000 } else if (@Activation.sort().join() == "A,B") { 15000 } else if (@Activation.sort().join() == "A,C") { 20000 } else if (@Activation.sort().join() == "B,C") { Wrong } else if (@Activation.sort().join() == "A,B,C") { 25000 } else {0}

  • Hi Alex, don't worry, just save the calculation. The notification you only get, cause no category was selected. Your calculation is ok and will work. You could add another condition: }else if (@activation == null){0}. One tip: At the beginning of your calculation declare @Activation as a variable like: var act = @Activation; Then you can use: act == "value" instead of always selecting the token @Activation. Saves time and you can copy the whole code easier if needed . Rainer rg@delos-consulting.com
This question is closed.