Skip to main content

Search

Formatting Numbers in Document Generation

Comments

3 comments

  • Official comment
    skybow support

    Hi Raoul Dobal,

    next to the approach mentioned by Henning EibenĀ (thanks a lot Henning) using curly brackets to use multi line code you could also use the single line place holder notation starting with an = symbol -> [[= your JS code]]

    For Number and also date formatting I often use the .toLocaleString function. Therefore you can use the following placeholder in your word template:

    [[=[[NumberField]].toLocaleString("de-CH")]]

    or if you need to pass other parameters as in the documentation below:

    [[=[[NumberField]].toLocaleString("de-CH", { minimumFractionDigits: 2, maximumFractionDigits:2 })]]

    Number: https://www.w3schools.com/jsref/jsref_tolocalestring_number.asp

    Date: https://www.w3schools.com/jsref/jsref_tolocalestring.asp

  • Henning Eiben

    Assuming you have a field called "MyNumberField" you could try something like this:

    [[{ return new Intl.NumberFormat('de-CH').format([[MyNumberField]]) }]]
    0
  • Raoul Dobal

    Thank you very much - both work. My word files now look much nicer.

    0

Please sign in to leave a comment.