Azure Logic Apps - Word Online connector - Populate Word template trims whitespaces

Bert Kamphuis 21 Reputation points
2023-05-04T08:41:28.58+00:00

Hi,

We created a Logic Apps flow to populate a Word template file with JSON data from a HTTP request.

Everything is working well, except for JSON values which have leading or subsequent whitespaces or whitespace(s) only as the value. In these cases somehow the Word Online (Business) Connector trims the whitespace unwanted.

Example

  • JSON
{"InvoiceTotalQuantityPrefix": " uur"}

Please note the whitespace in the JSON before the text value 'uur'

  • Content control in template

User's image

  • Result
    User's image

Note that the space is missing in the generated document.

The strange thing is that if we open the generated document in Word Online (which is saved in Sharepoint online), the whitespace is visible. Once we open the document in Word Desktop or save it to a PDF file, the whitespace is gone.
Result in Word Online:
PopulateWordTemplateWordOnlineResult

Result in PDF:
ResultPDF

We have no clue at all why this occurs.

Is there a solution to not let whitespaces be trimmed automatically? We do want to keep whitespaces explicitly set in the input JSON file.

Regards,

Bert

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,845 questions
{count} votes

Accepted answer
  1. Sonny Gillissen 3,271 Reputation points
    2023-06-09T03:17:48.1233333+00:00

    Hi Bert Kamphuis

    Thanks for reaching out on Microsoft Q&A!

    Leading or trailing whitespaces could potentially always result in strange behaviour.

    I would like to advise you not to use it in the contents of the data, but add it directly to the template between the two text controls.

    That way there can’t be any strange conversion whatsoever as it is fixed in the template. It’s best to avoid any whitespaces around your data itself (within isn’t an issue).

    If you want it to be dynamic, let’s say: sometimes you need a whitespaces and sometimes you don’t, it’s best to use only one content control. Within the flow of your Logic App you could merge the two values using the concat() function, like for example:

    concat(body('your_action')['your_value'),' uur')

    When using the snippet above you can still be dynamic whether or not you’d want a whitespace between your value and the unit, but make it writeable to only one control.

    Please click ‘Accept answer’ if you think my answer is helpful. Feel free to drop additional queries in the comments below!

    Kind regards,

    Sonny

    0 comments No comments

0 additional answers

Sort by: Most helpful