none
Liquid template math operation not working

    Question

  • In my policy I  have a <set-body template="liquid"> which converts from soap to json.

    I have a line like this for a field called TotalAmount and all I want to do is make this a calculated field from two objects in the original response so TotalAmount = Amount1 - Amount2.

    I looked up the docs for liquid templates and it says I can use a | minus operation but the calculation doesn't seem to get interpreted at all.

    This what I have:-

    "TotalAmount" : {{body.envelope.body.Amount1 | minus:body.envelope.body.Amount2}}

    However the outout for "TotalAmount" is always just the amount for body.envelope.body.Amount1.
    What is the right way to perform a subtraction?

    Thursday, March 8, 2018 11:47 AM

Answers

  • I would suggest you try “Minus” instead of “minus” as below and see if it helps,

    “TotalAmount" : {{body.envelope.body.Amount1 | Minus:body.envelope.body.Amount2}}

    -----------------------------------------------------------------------------------------------------

    Do click on "Mark as Answer" on the post that helps you, this can be beneficial to other community members.

    Friday, March 9, 2018 2:53 AM
    Moderator

All replies

  • I would suggest you try “Minus” instead of “minus” as below and see if it helps,

    “TotalAmount" : {{body.envelope.body.Amount1 | Minus:body.envelope.body.Amount2}}

    -----------------------------------------------------------------------------------------------------

    Do click on "Mark as Answer" on the post that helps you, this can be beneficial to other community members.

    Friday, March 9, 2018 2:53 AM
    Moderator
  • I can confirm that this works. Filter names are case-sensitive.
    Friday, March 9, 2018 7:34 PM