Not able to use if condition inside sum handlebar's helper

Comments

1 comment

  • Stephen Brandt Documentation Manager Community moderator
    Engaged
    Great Answer
    Top Contributor
    Celigo University Level 3: Master

    Hi, Dominik Antalík. That error reflects a handlebars limitation. Control-flow block helpers like #if cannot be placed inside helper methods like sum(). 

    You might want to consider an alternative approach, such as...

    • Checking for the tax value in a #compare statement before you do the math. The downside here is that #compare applies only to one value at a time. Then, you would likely have to nest comparisons levels down to cover the cases of more than one value at zero.
    • Starting over with JavaScript, as a hook or in a transform, to add a summary tax field to each record. 

    I was also wondering whether it might help to round certain rates down, if it's known that they have a negligible effect on the total. 

    0

Please sign in to leave a comment.